How to download file from gitlab project "uploads" via command line

Viewed 623

I tried to use curl with a private token:

curl --head --header "PRIVATE-TOKEN: xxxxxxxxx" -L "https://gitlab.name.com/<group>/<project>/uploads/<hash>/file.tar.gz"

but always redirects to login page

1 Answers

That was requested with issue 55520, now issue 25838:

It's possible to upload a file using the api (POST /api/v4/:project_id/uploads) but there is no way to retrieve the uploaded files (it used to be possible using the Private-Token auth and the web route /:namespace_id/:project_id/uploads/:secret/:file_name)

Edit by @Andysoiron: It seems to be still possible to retrieve the file using /:namespace_id/:project_id/uploads/:secret/:file_name

Andy added:

. I tried to reproduce it locally by uploading a file using POST /projects/:id/uploads and then retrieving it using GET /:namespace_id/:project_id/uploads/:url (I took url from the response of the POST request) and it worked.

Apparently:

You can't use a Private-Token for auth you need a Cookie: _gitlab_session because GET /:namespace_id/:project_id/uploads/:secret/:file_name come from the front-end.

So this is in progress, as part of issue 197361.

Related