Repository navigation
R2 file storage fixes, plus public type fixes. 0.4.0 was published minutes before these, so a few R2 behavior changes ship in this patch; see Changed.
Changed
/cloudflare/geolocationresponds 401 when signed out and 404 when nocfcontext is available, instead of 200 with anerrorbody. On the server,auth.api.getGeolocation()throwsAPIError(#77)createR2Storage()no longer returnslistUserFiles; list files through/files/list(authClient.files.list) (#79)- List cursors are opaque strings. A cursor from 0.4.0 (a file id) returns 400, so restart from the first page.
listFilesSchemaparsescursorand requires an integerlimitof at least 1 (#79) - R2
beforehooks (upload,download,delete,list) that returnnullrespond 403 instead of 500 (#77, #79) - With
allowedTypesset, an allowed extension is accepted with anyContent-Type. Before, the type also had to match the extension's MIME type (#78) - The client percent-encodes
x-filename. Deploy the server before the client: a 0.4.0 server would store the encoded name, e.g.%E2%82%AC.txt(#76)
Fixed
- R2 uploads with
allowedTypesunset accept any file type instead of returning 415 for everything but JSON (#75) - R2 validation errors return 400, 413 or 415 and blocked upload hooks return 403, instead of 500 (#77)
- R2 downloads send the filename as RFC 5987
filename*, so a crafted name can no longer inject a second filename, and non-ASCII names round-trip instead of becoming?. Names with control characters are rejected with 400. Clients older than this release that send a name containing a valid%XXsequence have it stored decoded (#76) - R2 uploads store the exact request bytes. Before, types the body parser didn't handle (csv, zip, mp3, markdown) were stored as the text
[object ReadableStream], and binary sent as text was re-encoded. Empty files upload.allowedTypesis enforced by file extension only, downloads sendX-Content-Type-Options: nosniffandContent-Security-Policy: sandbox, and themimedependency is gone (#78) - R2 file listing paginates in the database query, so every file is reachable, including uploads that share a millisecond.
files.listis a GET, so the client call isfiles.list({ query: { limit, cursor } }).limitabove 100 is capped at 100. The cursor is an opaque string, and list hooks now run (#79) - R2 upload failures no longer send internal error messages (from R2, the database or hooks) to the client; they return the generic
UPLOAD_FAILEDmessage and are still logged (#80) - R2 uploads without
Content-Lengthare counted while they stream and stop with 413 atmaxFileSizeinstead of being buffered whole. Filenames with C1 controls or bidi override characters are rejected with 400. Listing stays exact when more than 100 uploads share a timestamp and under case-insensitive database collations. The size error states the limit in bytes (#81) - Public types:
kv,r2.bucketandd1Nativeaccept any copy of the Workers types (global with the DOM lib, module import, orwrangler types) instead of failing or degrading toany, so@cloudflare/workers-typesis no longer a peer dependency.$Infer.Sessionincludes the geolocation fields on server and client, andauth.api.uploadand the other R2 endpoints are no longer possiblyundefinedwhenr2is configured (#82)