Это то, что я использую в одном из моих скриптов сборки:
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
, который добавляет вывод команды кфайл журнала, а также отобразить его на stdout
.Часть test ${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.