API · s5w

File delivery

Files are served from three addresses — depending on who may see them and for how long.

Three channels

/o
Public

/o/{bucketId}/{id} — no authorization, public files only.

/p
By token

/p/{id} — with a bucket token, BASIC is enough. For any file.

The ready addresses come in the upload response: publicUrl and privateUrl. They are built from PUBLIC_BASE_URL when it is set.

bash
# public
curl -O https://s5.example.com/o/<bucketId>/<id>

# by token
curl -O -H "Authorization: Bearer <token>" https://s5.example.com/p/<id>

Download instead of opening

Images, video, audio, PDF and plain text open in the browser by default (inline); everything else downloads. SVG and HTML always download: shown by the browser, they could run a script on behalf of your domain.

To make the browser save even what it can show, add ?download=1:

text
https://s5.example.com/o/<bucketId>/<id>?download=1

For a temporary link this is set when the link is issued — by the disposition field.

CDN-ready

All three channels support:

  • Range — resuming downloads and seeking in video (206 Partial Content; outside the file — 416). The exception is a temporary link with a download limit: it serves the file whole only;
  • ETag and conditional requests — If-None-Match answers 304 when the file has not changed;
  • Cache-Control — by the cache policy of the bucket and the folder.

Traffic

Every delivery is counted in the bucket statistics: volume served, received and the number of requests per day. The counters are flushed to the database every 20 seconds.