gpt4 book ai didi

cURL:上传时如何显示进度信息?

转载 作者:行者123 更新时间:2023-12-03 07:13:35 36 4
gpt4 key购买 nike

我使用以下语法来上传文件:

curl --form upload=@localfilename --form press=OK [URL]

如何显示进度?谢谢。

最佳答案

这是我在我的构建脚本之一中使用的内容:

curl "${UPLOAD_URL}" \
--progress-bar \
--verbose \
-F build="${BUILD}" \
-F version="${VERSION}" \
-F ipa="@${IPA};type=application/octet-stream" \
-F assets="@-;type=text/xml" \
-F replace="${REPLACE}" \
-A "${CURL_FAKE_USER_AGENT}" \
<<< "${ASSETS}" \
| tee -a "${LOG_FILE}" ; test ${PIPESTATUS[0]} -eq 0

-F-A您可能对选项不感兴趣,但有用的部分是:

curl "${UPLOAD_URL}" --progress-bar

这告诉 curl在上传过程中显示进度条(而不是默认的“进度表”),并且:

 | tee -a "${LOG_FILE}" ; test ${PIPESTATUS[0]} -eq 0

将命令的输出附加到日志文件中,并将其回显到 stdouttest ${PIPESTATUS[0]} -eq 0部分使得该行(位于 bash 脚本中)的退出状态与 curl 的退出代码相同。命令返回,而不是 tee 的退出状态命令(必需的,因为 tee 实际上是该行中执行的最后一个命令,而不是 curl )。

<小时/>

来自 man curl :

PROGRESS METER
curl normally displays a progress meter during operations, indicating the
amount of transferred data, transfer speeds and estimated time left, etc.

curl displays this data to the terminal by default, so if you invoke curl
to do an operation and it is about to write data to the terminal, it disables
the progress meter as otherwise it would mess up the output mixing progress
meter and response data.

If you want a progress meter for HTTP POST or PUT requests, you need to
redirect the response output to a file, using shell redirect (>), -o [file]
or similar.

It is not the same case for FTP upload as that operation does not spit out
any response data to the terminal.

If you prefer a progress "bar" instead of the regular meter, -# is your
friend.

OPTIONS
-#, --progress-bar
Make curl display progress as a simple progress bar instead of the
standard, more informational, meter.

关于cURL:上传时如何显示进度信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9973056/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com