[英]How to upload an asset from Azure Release pipeline to Github Enterprise using Bash
[英]How to upload github asset file using CURL
我想在我的桌面上上傳一個名為“hello.txt”的文件到我的 git 存儲庫,它有一個版本。 我該怎么做呢? 我閱讀了 git 文檔,但它說的是:
POST https://<upload_url>/repos/:owner/:repo/releases/:id/assets?name
。 如何在 CURL 中做到這一點。 我不明白這一點。
如何將此文件作為發布資產發布到我的 github 發布? 謝謝
curl \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: $(file -b --mime-type $FILE)" \
--data-binary @$FILE \
"https://uploads.github.com/repos/hubot/singularity/releases/123/assets?name=$(basename $FILE)"
擴展@galeksandrp 的回答,以下是我遇到的一些問題
請注意, --data-binary
選項首先將文件內容復制到 RAM,因此,如果您有大文件說接近 2048MB,即 github 版本的絕對限制,出於某種原因,如果 RAM 不夠,它會失敗curl: option -d: out of memory
。
解決方法是使用-T file path
(不帶 @),如果您想查看上傳進度,您需要將輸出通過管道傳輸到 cat,例如curl <...the whole command> | cat
curl <...the whole command> | cat
所以完整的命令看起來像這樣
curl -X POST \
-H "Content-Length: <file size in bytes>" \
-H "Content-Type: $(file -b --mime-type $FILE)" \ #from @galeksandrp's answer
-T "path/to/large/file.ext" \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://uploads.github.com/repos/<username>/<repo>/releases/<id>/assets?name=<name> | cat
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.