Is there a way to do this using only wget (or curl or some other linux terminal command)? Git is not installed on the machine from which this command will be run.
Currently I am being given a 404 Not Found error when I attempt to download the lib folder of my repo by running this command:
wget --header="Authorization: token {token}" -r https://raw.githubusercontent.com/{user}/{repo}/{branch}/{path to builds dir}/lib
The directory definitely exists and the following code downloads a file from within the directory just fine:
wget --header="Authorization: token {token}" --output-document={file}.jar https://raw.githubusercontent.com/{user}/{repo}/{branch}/{path to builds dir}/lib/{file}.jar
This is the solution you'll need if you want to accomplish this task programmatically. And this is actually what DownGit is using under the hood. Using GitHub's REST API, write a script that does a GET request to the content endpoint. The endpoint can be constructed as follows: https://api.github.com/repos/:owner/:repo/contents/:path. After replacing the placeholders, an example endpoint is: https://api.github.com/repos/babel/babel-eslint/contents/lib. This gives you JSON data for all of the content that exists in that folder. The data has everything you need, including whether or not the content is a folder or file, a download URL if it's a file, and an API endpoint if it's a folder (so that you can get the data for that folder). Using this data, the script can recursively go through all content in the target folder, create folders for nested folders, and download all of the files for each folder. Check out DownGit's code for inspiration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With