import type { S3Client } from "@aws-sdk/client-s3"; import type { R2Bucket } from "@cloudflare/workers-types"; import type { Adapter } from "../index.js"; export interface R2HttpOptions { /** R2 bucket name. */ bucket: string; /** * Cloudflare account ID. Falls back to `R2_ACCOUNT_ID` env var; required * if no env var is set. */ accountId?: string; /** * R2 access key ID. Falls back to `R2_ACCESS_KEY_ID` env var; required if * no env var is set. */ accessKeyId?: string; /** * R2 secret access key. Falls back to `R2_SECRET_ACCESS_KEY` env var; * required if no env var is set. */ secretAccessKey?: string; /** * Origin used to build URLs from `url()` — typically an `r2.dev` * subdomain or a custom domain bound to the bucket. When set, `url()` * returns `${publicBaseUrl}/${key}` and skips signing. When unset, * `url()` returns a presigned GetObject URL (default expiry: 1 hour). */ publicBaseUrl?: string; /** * Default expiry, in seconds, for `url()` when `publicBaseUrl` is unset. * Defaults to 3600. */ defaultUrlExpiresIn?: number; } export interface R2BindingOptions { /** Workers `R2Bucket` binding. Reads and writes go through the binding. */ binding: R2Bucket; /** R2 bucket name. Only used to label errors when reading via the binding. */ bucket?: string; /** * Origin used to build URLs from `url()` — typically an `r2.dev` * subdomain or a custom domain bound to the bucket. Without this (and * without HTTP credentials below), `url()` throws because a Workers * binding has no signing primitive. */ publicBaseUrl?: string; /** * Hybrid mode: Cloudflare account ID, used alongside `accessKeyId` + * `secretAccessKey` so `url()` and `signedUploadUrl()` can fall back to * the S3-compatible HTTP signer instead of throwing. Reads and writes * still go through the binding so they stay intra-Worker (no egress * fees). Useful for Workers that need browser-facing presigned URLs * without giving up the binding's I/O performance. */ accountId?: string; /** Hybrid mode: R2 access key ID. See `accountId`. */ accessKeyId?: string; /** Hybrid mode: R2 secret access key. See `accountId`. */ secretAccessKey?: string; /** * Default expiry, in seconds, for `url()` when it falls back to HTTP * signing (hybrid mode without `publicBaseUrl`). Defaults to 3600. */ defaultUrlExpiresIn?: number; } export type R2AdapterOptions = R2BindingOptions | R2HttpOptions; export type R2Adapter = Adapter; export declare const r2: (opts: R2AdapterOptions) => R2Adapter; export type { R2Bucket } from "@cloudflare/workers-types"; //# sourceMappingURL=index.d.ts.map