download headers
A stored file's GET sends Content-Length and Accept-Ranges, answers * to any Origin and allows a Range preflight, so a page can show progress, resume with Range and abort. HEAD is 403.
API
Q Does the stored file's GET (an Attachment's this_file.url) send Content-Length, can a page read
it and the body under CORS, does it honour Range, and can the body be cancelled after the headers?
Endpoint GET <this_file.url> ; GET /entity/<type>/<id>/<field>
Docs claim Silent. Probe 125 read a stored file once and found access-control-allow-origin: *.
Actual
this_file.url: <bucket>.s3-accelerate.amazonaws.com, X-Amz-Expires 900; answered through CloudFront
GET, Origin https://example.invalid -> 200, 20000000 b in 1.4 s, bytes identical
content-length: 20000000 accept-ranges: bytes content-type: binary/octet-stream
content-disposition: filename="zzprobe_141.jpg"
access-control-allow-origin: * access-control-allow-methods: GET, HEAD, PUT
access-control-expose-headers: ETag access-control-max-age: 0
HEAD on the same URL -> 403, content-type application/xml
OPTIONS, ACRM GET, ACRH range -> 200, access-control-allow-headers: range
GET, Range bytes=0-1023 -> 206, 1024 b, the first KiB
content-range: bytes 0-1023/20000000
streamed: headers after 0.15 s; 64 KiB read, connection closed at 0.16 s
the same URL straight after, Range bytes=-16 -> 206, 16 b
GET /api/v1/entity/attachments/<id>/this_file -> 200 JSON: content_type, id, link_type, name, type, url
What a page on another origin can do
| need | header | readable by script |
|---|---|---|
| total size, for progress | Content-Length |
yes: CORS-safelisted, and the response is * |
| resume a download | Range request, 206, Content-Range |
the request yes (preflight allows range); Content-Range is not exposed, use Content-Length of the 206 and the offset sent |
| abort | AbortController on the fetch |
nothing server-side to call |
| the file's MIME type | Content-Type |
yes; it is what the upload PUT sent, here none, so binary/octet-stream |
Teaches
- Show progress from
Content-Length: it is sent on the 200, and a script may read it under*. HEADis refused because the URL is signed forGET. Read size withGETandRange: bytes=-1(probe 140), or from the 200's headers before reading the body.- Abandoning a body is a client-side close; the URL stays usable for a new request until it expires 900 s after it was read from the API. What S3 bills for a closed transfer was not measured.
- The stored
Content-Typeis S3's defaultbinary/octet-streamwhen the uploadPUTsends none, as this one did; the.jpgname does not set it.Content-Typeis not a signed header (probe 125), so aPUTmay send one, and the download then answers with it (probe 152). - Evidence is headers read by a process. A browser applying the CORS rules to them allows the above; no browser was run.