Upload a File With curl and Get a CDN URL
The 3-Command curl Upload: POST, PUT, Confirm
POST for a presigned URL, curl -X PUT the bytes, POST confirm — three copy-paste commands and your file has a permanent CDN link.
curl is the whole SDK here. Uploading a local file to cdn22.net and getting a permanent CDN URL back takes three HTTP calls in a fixed order: POST the file's metadata to get a presigned URL, PUT the bytes to that URL, then POST to confirm. Every command below is copy-paste — swap in an API key from your API keys page and a folder id from the dashboard. The auth header is the raw key value, with no Bearer prefix.
Step 1 asks the API for somewhere to put the bytes.
# Step 1 — request a presigned upload URL
curl -sf -X POST https://api.cdn22.net/v1/files/<FOLDER_ID> \
-H "Authorization: $CDN22_API_KEY" \
-H "Content-Type: application/json" \
-d '{"filesMetadata":[{"name":"report.pdf","size":248173,"type":"application/pdf"}]}'
# Response
# {
# "success": true,
# "urls": [
# { "url": "https://<bucket>.s3.<region>.amazonaws.com/...&X-Amz-Signature=...",
# "id": "1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed",
# "key": "<owner>/<folder>/report.pdf" }
# ]
# }Step 2 sends the file itself. This PUT goes to storage, not to the API, so it carries no Authorization header at all — the signature already baked into the presigned URL is the authorization. Sending your API key here is the single most common way this flow breaks.
# Step 2 — PUT the bytes to the presigned URL. No auth header, and quote the URL.
curl -sf --upload-file ./report.pdf \
-H "Content-Type: application/pdf" \
"https://<bucket>.s3.<region>.amazonaws.com/...&X-Amz-Signature=..."--upload-file is the command-line face of libcurl's CURLOPT_UPLOAD: it streams the file straight from disk and implies -X PUT, so you never need both. curl -X PUT --data-binary @report.pdf moves the same bytes but buffers the file first, so prefer --upload-file for anything large. Add -# for a progress bar, and --retry 3 --retry-connrefused so a dropped connection re-attempts the transfer instead of failing the whole pipeline.
Step 3 finalizes the file, and the CDN URL goes live.
# Step 3 — confirm the upload with the id from step 1
curl -sf -X POST https://api.cdn22.net/v1/files/confirm-upload \
-H "Authorization: $CDN22_API_KEY" \
-H "Content-Type: application/json" \
-d '{"ids":["1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed"]}'
# A public file is now served from:
# https://cdn.cdn22.net/<owner>/<folder>/report.pdfTo stop copy-pasting ids by hand, capture step 1's response and pull the fields out with jq. That is a complete uploader in about ten lines — drop it in your shell profile and upload report.pdf works on any machine that has curl and jq.
upload() {
resp=$(curl -sf -X POST https://api.cdn22.net/v1/files/<FOLDER_ID> \
-H "Authorization: $CDN22_API_KEY" -H "Content-Type: application/json" \
-d "$(jq -n --arg n "$(basename "$1")" \
--argjson s "$(wc -c < "$1" | tr -d ' ')" \
'{filesMetadata:[{name:$n,size:$s,type:"application/octet-stream"}]}')")
curl -sf --retry 3 --upload-file "$1" "$(jq -r '.urls[0].url' <<< "$resp")"
curl -sf -X POST https://api.cdn22.net/v1/files/confirm-upload \
-H "Authorization: $CDN22_API_KEY" -H "Content-Type: application/json" \
-d "$(jq -c '{ids:[.urls[0].id]}' <<< "$resp")"
}Because every call is plain HTTPS on port 443, the same commands run from a laptop, a cron job, a Docker image, GitHub Actions, or GitLab CI with no credentials file to distribute — unlike aws s3 cp, the only secret is the one API key already in your environment. Keep -f on the two API calls so a non-2xx response sets a non-zero exit code your CI step can actually catch.
Need the same flow from somewhere other than a shell? The full upload-a-file guide walks the identical three calls from curl, the browser, and Node.js. The cloud file storage API covers the wider endpoint set, file upload CLI covers shell ergonomics, API-key auth covers key handling and rotation, and Node.js and Python port the same three calls into a runtime.
Pricing is prepaid credits with no subscription — you pay for the storage and bandwidth you actually use, so a script pushing a few build artifacts costs a few cents. Create an API key and run the commands above against your own folder.
Benefits With No Complexity
Global CDN delivery
Edge-cached worldwide
Signed-URL security
What You Get
Unlimited files
Unlimited storage
Public + Private storage
CDN ready links
Prepaid credits
More coming soon
How cdn22.net Works
1. Upload
2. Copy
3. Use Anywhere
Why Developers Choose cdn22.net
A Better Way to Store & Deliver Files
| aws s3 cp | scp / rsync | FTP client | cdn22.net | |
|---|---|---|---|---|
| Three plain HTTP calls, no SDK | ||||
| Single API key, no credentials file | ||||
| All traffic over HTTPS/443 (proxy-friendly) | ||||
| Returns a shareable delivery URL | ||||
| Built into Linux/macOS/Windows 10+ |
Calculate Your Needs
Storage
Egress
CDN Bandwidth
Create an API Key and Upload with curl
- Global CDN delivery
- Edge-cached worldwide
- Signed-URL security
- Unlimited files
- Unlimited storage
- Public + Private storage
- No subscription — prepaid credits keep spend predictable