fen*_*tas 7 bash curl file-upload chunks
我想上传一个大文件curl
。为此,我想将其拆分,而不将其保存到磁盘(就像使用split
)。--continue-at
我尝试与 一起使用Content-Length
。
curl -s \
--request PATCH \
--header "Content-Type: application/offset+octet-stream" \
--header "Content-Length: ${length}" \
--header "Upload-Offset: ${offset}" \
--continue-at "${offset}" \
--upload-file "${file}" \
"${dest}"
Run Code Online (Sandbox Code Playgroud)
但curl
“过冲”并忽略了Content-Length
。有类似的东西--stop-at
吗?或者,如果有必要,我必须使用dd
。
编辑
dd
解决方案:
curl -s \
--request PATCH \
--header "Content-Type: application/offset+octet-stream" \
--header "Content-Length: ${length}" \
--header "Upload-Offset: ${offset}" \
--data-binary "@-" \
"${dest}" < <(dd if=${file} skip=${offset} count=${length} iflag=skip_bytes,count_bytes 2>/dev/null)
Run Code Online (Sandbox Code Playgroud)
但如果可能的话我想只使用 cURL..