Skip to main content
storage provides access to your project’s R2 buckets. Import it from edgespark and pass bucket declarations from @defs.

storage.from(bucket)

server/src/index.ts

S3 URI helpers

Use S3 URIs when you want to persist a file reference in your own database:
server/src/index.ts
If the input may be invalid, use tryParseS3Uri(...):

Upload and download

server/src/index.ts

Read metadata without downloading the file

Use head(...) when you only need metadata:
server/src/index.ts

List and delete

server/src/index.ts
delete(...) also accepts multiple paths:

Paginate or group list results

list(...) supports pagination and delimiter-based grouping:
server/src/index.ts

Presigned uploads

server/src/index.ts

Presigned downloads

server/src/index.ts
Use presigned URLs for large client uploads and downloads. See platform limits for file size and runtime constraints.

See also

Use storage

Declare buckets, apply them with the CLI, and use storage from your routes.

Build a REST API

Complete example with presigned uploads and file references.
Last modified on April 7, 2026