Object storage backed by Cloudflare R2.
getStream is implemented, so a download can be piped straight to the
response through IResponse.stream() without buffering the object.
getSignedUrl throws: the R2 Workers binding exposes no presigned-URL
capability at all. Serving an object through a Worker route, or fronting the
bucket with a custom domain, are the available alternatives, and the error
says so.
R2Storage(bucket: IR2Bucket,options?: R2StorageOptions)
delete(path: string): Promise<boolean>
Deletes an object.
exists(path: string): Promise<boolean>
Reports whether an object exists.
get(path: string): Promise<Uint8Array>
Retrieves an object.
getSignedUrl(path: string,_options: SignedUrlOptions): Promise<string>
Always throws — R2 bindings cannot presign.
The unused _options is kept, not deleted. Dropping it would narrow the
exported class below IStorage, so a consumer holding an
R2Storage directly could no longer pass SignedUrlOptions —
the interface still declares it. An underscore is the sanctioned way to
mark a parameter a contract requires and an implementation cannot use.
getStream(path: string): Promise<ReadableStream<Uint8Array>>
Streams an object without buffering it.
put(): Promise<void>
Writes an object, translating PutObjectOptions into R2's own
spelling: the content type lives under httpMetadata, user metadata under
customMetadata. Without this every object was served as
application/octet-stream (X8-6).