Downloading a file from own repository #23955
-
How can I download a file from my repository? I can log in or I can request something with a token from GitHubGitHub: Where the world builds softwareGitHub is where over 56 million developers shape the future of software, together. Contribute to the open source community, manage your Git repositories, review code like a pro, track bugs and feat... But I always get 404 as response. |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments
-
Could you describe exactly how you’re trying to download the file? |
Beta Was this translation helpful? Give feedback.
-
I tried it with the urls given by github and https. |
Beta Was this translation helpful? Give feedback.
-
I do not know, how I can get a valid URL for a file in my repository to be able to download it. It seams that the URLs under “raw” with the token expire very soon. And with login and RBTCGP/NeoLoad/blob/komplett/PH78.yaml I get “The connection was unexpected disconnected” wget https://RBTCGP:[email protected]/RBTCGP/NeoLoad/blob/komplett/PH78.yaml wget : Die Anfrage wurde abgebrochen: Die Verbindung wurde unerwartet getrennt…
|
Beta Was this translation helpful? Give feedback.
-
You’ll need to create a PAT and send that in the
That’s not going to work, because those tokens have a limited lifetime. You’ll have to create a Personal Access Token (PAT) and download the files using that, using the Authorization header instead of a token in the URL. Something like this: curl -H "Authorization: token ${PAT}" https://raw.githubusercontent.com/user/repo/main/file.txt That example uses curl, but you should be able to do the same thing with the |
Beta Was this translation helpful? Give feedback.
-
Many thanks, it works! Nevertheless, is there also a possibility to get a link to a zip of the files in a repository branch without putting them into a folder and zipping the folder? I need the files in the root of the folder. |
Beta Was this translation helpful? Give feedback.
-
You can use the URL behind the “Download ZIP” field in the popup that shows up if you click the green “Code” button on your repository page. The |
Beta Was this translation helpful? Give feedback.
-
Yes, but this puts the files into a folder and zips the folder. I need the files in the root of the zipped folder without any folder inbetween. |
Beta Was this translation helpful? Give feedback.
-
There’s no built-in mechanism for that. You could set up an Actions workflow to build a ZIP just like you need it, but I’d just move files into place after extraction (write a script to do that) unless the ZIP needs to be processed by some tool you can’t adjust. |
Beta Was this translation helpful? Give feedback.
You’ll need to create a PAT and send that in the
Authorization
header to download from the raw URL, as described here: