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
Retry transient failures
curl --retry 5 --retry-delay 2 -O https://example.com/archive.tgz

# Retry transient connection and timeout errors.

Retry on all errors
curl --retry 5 --retry-all-errors -O https://example.com/archive.tgz

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

Save using Content-Disposition filename
curl -OJ https://example.com/download

# Use server-provided filename from headers.

Create local directories
curl --create-dirs -o downloads/reports/out.pdf https://example.com/report.pdf

# Create local directories automatically for output paths.

Limit transfer rate
curl --limit-rate 500K -O https://example.com/large.bin

# Cap the download or upload speed.

Fail slow transfers
curl --speed-limit 1024 --speed-time 30 -O https://example.com/file.bin

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

Use a curl config file with URLs
curl --config urls.txt

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

URL globbing with lists
curl -O 'https://example.com/{a,b,c}.txt'

# Download several related URLs using brace expansion.

Download a numbered range
curl -O 'https://example.com/logs/app[1-5].txt'

# Download multiple similarly named files.

## Uploads
Upload from stdin
printf 'hello
' | curl -T - https://example.com/upload.txt

# Pipe content into curl and upload it as request body.

Upload a file over SFTP
curl -u user:pass -T ./backup.sql sftp://example.com/home/user/backup.sql

# Transfer a file to an SFTP destination.

Upload a file over FTP
curl -u user:pass -T ./site.zip ftp://example.com/incoming/site.zip

# Send a file to an FTP server.

Append to a remote file
curl --append -T ./log.txt ftp://example.com/log.txt

# Append uploaded data when the protocol and server support it.

Send an email via SMTP
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'

# Submit an email message using SMTP.

Recommended next

No recommendations yet.