import { S3Client } from '@aws-sdk/client-s3'; import { Adapter, FilesErrorCode, FilesError } from '../index.js'; interface S3AdapterOptions { bucket: string; region?: string; endpoint?: string; forcePathStyle?: boolean; credentials?: { accessKeyId: string; secretAccessKey: string; sessionToken?: string; }; /** * Origin used to build URLs from `url()`. When set, `url(key)` returns * `${publicBaseUrl}/${key}` and skips signing — appropriate for buckets * fronted by a CDN, public-read policy, or custom domain. When unset, * `url()` falls back to a presigned `GetObject` URL (see * {@link defaultUrlExpiresIn}). * * The base is concatenated as-is. Trailing slashes are tolerated. Keys * are embedded literally — caller is responsible for URL-encoding * untrusted segments. */ publicBaseUrl?: string; /** * Default expiry, in seconds, for the presigned URLs returned by * `url()` when `publicBaseUrl` is not set. Defaults to 3600 (1 hour). * Per-call `url(key, { expiresIn })` overrides. */ defaultUrlExpiresIn?: number; /** * Override the fallback message used when an unknown error has no * `message` of its own. Internal — set by the r2-http adapter so its * users see "R2 error" instead of "S3 error". * @internal */ defaultProviderMessage?: string; } type S3Adapter = Adapter & { readonly bucket: string; }; /** * Map an `@aws-sdk/client-s3` error (or any thrown value with the same * shape) to a {@link FilesError}. The optional `messages` argument * overrides the per-code fallback strings — used by the S3-compatible * wrappers (R2 HTTP, MinIO, DigitalOcean Spaces, Storj, Hetzner, Akamai) * so their unknown-error messages read with the right provider name. */ declare const mapS3Error: (err: unknown, messages?: Record) => FilesError; declare const s3: (opts: S3AdapterOptions) => S3Adapter; export { type S3Adapter, type S3AdapterOptions, mapS3Error, s3 };