使用已上传到 GHE 版本的 cURL 下载文件

Download a file using cURL that has been uploaded to a GHE release

我正在使用 GitHub Enterprise 并且我将一个大型二进制文件上传到存储库的发布部分。下载文件的link是https://git.mycompany.com/theuser/therepo/releases/download/0.0.1-alpha/large.file.

使用 cURL 下载此文件的正确方法是什么?

每次我尝试 cURL 文件时,我都会收到一个响应,说我正在被重定向,或者我得到垃圾。我可以使用原始 link 将实际回购中的文件 cURL 到文件(在 URL 中有一个标记)。

我尝试了 cURL 与 GitHub API 和其他 URL 的各种组合,但没有任何效果。

Every time I try to cURL the file, I get a response saying that I'm being redirected

确保使用 curl -L 进行重定向。

or I get garbage back

确保使用 curl -O afile 否则下载结果将直接在标准输出上。

简而言之

curl -L -O afile https://git.mycompany.com/theuser/therepo/releases/download/0.0.1-alpha/large.file

或使用"Latest release asset" GitHub API, combined with this curl tutorial.

curl -vLJO -H 'Accept: application/octet-stream' 'https://api.github.com/repos/:owner/:repo/releases/assets/:id?access_token=:token'

在“How to download GitHub Release from private repo using command line”查看更多信息。

如果您的存储库不是私有存储库,您可能不需要令牌访问权限。