cURL Download and Upload Workflows

Comprehensive curl patterns for downloads, retries, upload flows, range requests, SMTP, SFTP, and batch transfers.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Downloads

Mirroring, retry logic, names, and batch workflows.

Retry transient failures

Retry transient connection and timeout errors.

bashANYcurlretrydownload
bash
curl --retry 5 --retry-delay 2 -O https://example.com/archive.tgz

Useful for flaky networks and CI pipelines.

Retry on all errors

Retry on all errors, including transient HTTP failures when appropriate.

bashANYcurlretryautomation
bash
curl --retry 5 --retry-all-errors -O https://example.com/archive.tgz

Stronger retry behavior for scripts and automation.

Save using Content-Disposition filename

Use server-provided filename from headers.

bashANYcurldownloadfilename
bash
curl -OJ https://example.com/download

`-J` works with `-O` to honor `Content-Disposition` names.

Create local directories

Create local directories automatically for output paths.

bashANYcurldownloadfilesystem
bash
curl --create-dirs -o downloads/reports/out.pdf https://example.com/report.pdf

Handy when writing into nested destination paths.

Limit transfer rate

Cap the download or upload speed.

bashANYcurlbandwidthdownload
bash
curl --limit-rate 500K -O https://example.com/large.bin

Useful when testing or conserving bandwidth.

Fail slow transfers

Abort a transfer if speed drops below a threshold for too long.

bashANYcurlperformancetimeouts
bash
curl --speed-limit 1024 --speed-time 30 -O https://example.com/file.bin

Good for automation where stuck connections should fail.

Use a curl config file with URLs

Use a curl config file to store repeated options and URLs.

bashANYcurlconfigbatch
bash
curl --config urls.txt

curl supports command-line option files via `-K` / `--config`.

URL globbing with lists

Download several related URLs using brace expansion.

bashANYcurlglobbingdownload
bash
curl -O 'https://example.com/{a,b,c}.txt'

curl supports URL globbing with lists and ranges.

Download a numbered range

Download multiple similarly named files.

bashANYcurlglobbingdownload
bash
curl -O 'https://example.com/logs/app[1-5].txt'

Use bracket ranges for bulk downloads.

Uploads

FTP/SFTP/HTTP uploads and stdin-driven transfers.

Upload from stdin

Pipe content into curl and upload it as request body.

bashANYcurluploadstdin
bash
printf 'hello
' | curl -T - https://example.com/upload.txt

`-T -` reads upload data from standard input.

Upload a file over SFTP

Transfer a file to an SFTP destination.

bashANYcurlsftpupload
bash
curl -u user:pass -T ./backup.sql sftp://example.com/home/user/backup.sql

curl supports SFTP as well as HTTP and HTTPS.

Upload a file over FTP

Send a file to an FTP server.

bashANYcurlftpupload
bash
curl -u user:pass -T ./site.zip ftp://example.com/incoming/site.zip

Classic FTP upload pattern.

Append to a remote file

Append uploaded data when the protocol and server support it.

bashANYcurlappendupload
bash
curl --append -T ./log.txt ftp://example.com/log.txt

Mostly used with FTP/SFTP style workflows.

Send an email via SMTP

Submit an email message using SMTP.

bashANYcurlsmtpmail
bash
curl --url 'smtp://mail.example.com:587' --ssl-reqd --mail-from 'me@example.com' --mail-rcpt 'you@example.com' --upload-file email.txt -u 'me@example.com:password'

curl supports SMTP and related mail protocols.

Recommended next

No recommendations yet.