5

I want to upload a big file with curl. For that, I want to split it, without saving it to disk (like with split). I tried to use --continue-at with 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}"

But curl "overshoots" and ignores Content-Length. Is there something like --stop-at? Alternatively, I have to use dd, if necessary.

EDIT dd solution:

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)

but if possible I would like to use only cURL..

fentas
  • 1,011
  • 12
  • 14

0 Answers0