Is it possible to download a file from GitLab using the API? I am using CentOS 6 commandline. The documentation for the API says “Get file from repository” but it is only to get the metadata and not the file itself. The example they give is:
curl --request GET --header 'PRIVATE-TOKEN: <your_access_token>' 'https://gitlab.example.com/api/v4/projects/13083/repository/files/test%2Epy/raw?ref=master'
If I use the raw option, it gives me the contents of the file, but it saves the name with as test%2Epy/raw?ref=master
How do I get it to save as test.py
?
2
Answers
Append
> test.py
tocurl
as below:It’s also possible to use the group and project name instead of the project-id:
It’s important to URL encode the group + project path and the file path as well.