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
tryParseS3Uri(...):
Upload and download
server/src/index.ts
Read metadata without downloading the file
Usehead(...) 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
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.