Switch to embedded reader
Clever Curl
2020-09-03T17:58:14.000ZMy personal cURL cheat sheet
Downloading files
Resuming failed download
Need to make sure filename is the same in order for it to automatically determine the offset. The -
after -C
tells it to use the output file to determine where to continue from.
curl -O -C - https://example.com/dir/filename.bin
Output filename
-O
uses the filename from the end of the path.
curl -O https://example.com/dir/filename.bin
This can be annoying if it has query parameters, because they will end up in the filename.
If you add -J
it lets curl use the filename provided by the server (via the Content-Disposition
header) if one is available.
curl -OJ https://example.com/dir/filename.bin?param=value
Uploading files
Prefer --data-binary
to --data/-d
because it doesn't mess with newlines etc.
curl https://example.com/dir/filename.bin --data-binary @filename.bin
-T
option will make a PUT request. Advantage over --data-binary
is that it doesn't load the entire
file into memory on the client. You can use -X POST
to force it to use POST.
curl https://example.com/dir/ -T filename.bin