Skip to content
CheckcraftDownload
Practical workflow

Download a file with curl: -o, -O, redirects and resume

Checkcraft is a desktop app for checking APIs and logs without code, with a free edition. Download, no sign-up →

Without flags curl prints the download to the console, so files need -o or -O. You almost always need -L too: download links often redirect. Below are commands for a normal download, resume, and checking you got the file and not an HTML error page.

Checkcraft ·

Get help with your first test →

-o or -O

-o name saves under the given name. -O takes the name from the last part of the URL. If the URL ends in download or has parameters the name will be odd: use -o, or -J with -O to take the name from Content-Disposition.

Do not save an error page

If the link expired, the server returns 404 or 403 with an HTML page and curl saves it under the archive name. -f makes curl fail on HTTP 400 and above and not write the error body to the file.

API call diagram: method and URL, headers, body, status and response body, logs and database

Resume and retries

Resume a broken large download with -C - and the same -o: curl checks the size already saved. On an unstable network add --retry with a count, and in scripts --max-time so the download never hangs forever.

Download commands

# сохранить под своим именем, пройти редиректы, не сохранять страницу ошибки
curl -fL -o report.zip https://files.example.com/download?id=42

# имя из адреса
curl -O https://files.example.com/builds/app-1.4.2.tar.gz

# имя из заголовка Content-Disposition
curl -OJ -L https://files.example.com/download?id=42

# докачать оборванную загрузку
curl -C - -o big.iso https://mirror.example.com/big.iso

# повторы и ограничение времени для скрипта
curl -fL --retry 5 --retry-delay 3 --max-time 600 -o big.iso https://mirror.example.com/big.iso
Layers of an API call check: status, headers, body, calculations, logs, database

Check you got the right file

  • The size looks right, not a few kilobytes.
  • The file command reports an archive or binary, not an HTML document.
  • The checksum matches the published one: sha256sum on Linux, certutil -hashfile on Windows.

If a download breaks with an error number, see curl errors.

More on curl

Section overview and all guides: curl command cheat sheet: flags and examples for APIs.

Frequently asked questions

How do I download a file with curl?

curl -L -o name URL; -O uses the URL name, -L follows redirects.

How do I resume?

Run the same command with -C - and the same -o name.

Why did curl save HTML?

The server returned an error or login page; add -f.

Next step

Repeat this on your own API

Checkcraft is a desktop app that saves API response checks without code and shows what did not match. Start with a sample, then use your own sanitized data. Free runs on Windows and Linux with no time limit.

Download FreeDownload and first run

No sign-up or email needed, the archive is ready in a couple of minutes. See the edition limits.

References

curl man page

Start with the linked example and compare its result with your own test requirement.

Ask a person

Get help with your first test

Tell us what you want to test or where you got stuck. We can help you start Checkcraft, choose an example and understand your first run. You can ask before downloading.

The Telegram group is public: do not post passwords, tokens or confidential work data. A description of your task is enough to start.

You can also email us support@checkcraft.ru

No account required. We will reply by email. This is a support request, not a newsletter subscription.