import { S3Client } from '@aws-sdk/client-s3'; import { R2Bucket } from '@cloudflare/workers-types'; export { R2Bucket } from '@cloudflare/workers-types'; import { Adapter } from '../index.js'; interface R2HttpOptions { bucket: string; accountId?: string; accessKeyId?: string; 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; } interface R2BindingOptions { binding: R2Bucket; 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: provide HTTP credentials alongside a Workers binding. * When all three are set, `url()` (when no `publicBaseUrl` is * configured, or when `responseContentDisposition` is requested) and * `signedUploadUrl()` route through the S3-compatible HTTP signer * instead of throwing. Reads and writes still go through * the binding so they stay intra-Worker (no egress fees, no extra * round trip). Useful for Workers that need browser-facing presigned * URLs without giving up the binding's I/O performance. */ accountId?: string; accessKeyId?: string; secretAccessKey?: string; /** * Default expiry, in seconds, for `url()` when it falls back to HTTP * signing (hybrid mode without `publicBaseUrl`). Defaults to 3600. */ defaultUrlExpiresIn?: number; } type R2AdapterOptions = R2BindingOptions | R2HttpOptions; type R2Adapter = Adapter; declare const r2: (opts: R2AdapterOptions) => R2Adapter; export { type R2Adapter, type R2AdapterOptions, type R2BindingOptions, type R2HttpOptions, r2 };