R2S3Transport.ts overview

AWS SDK transport for the R2 image store.

Since v0.12.0


constructors

fromS3

Use R2's S3-compatible API from a Bun or Node NFS server.

A store using this client enforces its per-store limit while reading the body. Direct calls to the client's legacy read still materialize the entire object.

Example

import { S3Client } from "@aws-sdk/client-s3"
import { fromS3 } from "@effect-vfs/persistence/R2S3Transport"
 
const s3 = new S3Client({
  region: "auto",
  endpoint: "https://ACCOUNT_ID.r2.cloudflarestorage.com",
  credentials: { accessKeyId: "ACCESS_KEY_ID", secretAccessKey: "SECRET_ACCESS_KEY" }
})
const client = fromS3(s3, "test-bucket")

Signature

declare const fromS3: {
  (bucket: string): (client: S3Client) => R2Client & Required<Pick<R2Client, "readBounded">>
  (client: S3Client, bucket: string): R2Client & Required<Pick<R2Client, "readBounded">>
}

Source

Since v0.5.0