【问题标题】:Download a file using cURL that has been uploaded to a GHE release使用已上传到 GHE 版本的 cURL 下载文件
【发布时间】:2017-03-23 22:03:15
【问题描述】:

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

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

每次我尝试 cURL 文件时,我都会收到一个响应,说我正在被重定向,或者我得到了垃圾。我可以使用文件的原始链接(在 URL 中有一个令牌)来卷曲实际存储库中的文件。

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

【问题讨论】:

    标签: github github-enterprise


    【解决方案1】:

    每次我尝试 cURL 文件时,我都会收到一条回复说我正在被重定向

    确保使用curl -L 来跟踪重定向。

    否则我会拿回垃圾

    确保使用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,结合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”查看更多信息。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-06
      • 2016-05-02
      • 2019-09-23
      • 2012-09-03
      • 2010-11-29
      • 2015-11-11
      • 1970-01-01
      相关资源
      最近更新 更多