简体   繁体   English

如何通过命令行从gitlab项目“上传”下载文件

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

I tried to use curl with a private token:我尝试将 curl 与私有令牌一起使用:

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

but always redirects to login page但总是重定向到登录页面

That was requested with issue 55520 , now issue 25838 :这是要求与问题55520 ,现在发行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 )可以使用 api ( POST /api/v4/:project_id/uploads ) 上传文件,但无法检索上传的文件(过去可以使用 Private-Token auth 和网络路由/: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 由@Andysoiron 编辑:似乎仍然可以使用/: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.我尝试通过使用POST /projects/:id/uploads然后使用GET /:namespace_id/:project_id/uploads/:url (我从 POST 请求的响应中获取 url)检索它来在本地重现它工作。

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.您不能使用Private-Token进行身份验证,您需要Cookie: _gitlab_session因为GET /:namespace_id/:project_id/uploads/:secret/:file_name来自前端。

So this is in progress, as part of issue 197361 .所以这是在进行中,作为issue 197361 的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM