import { S3Client } from "@aws-sdk/client-s3"; import type { Adapter } from "../index.js"; import { FilesError } from "../internal/errors.js"; import type { ProviderFilesErrorCode } from "../internal/errors.js"; export interface S3AdapterOptions { /** S3 bucket name. The adapter scopes all operations to it. */ bucket: string; /** * AWS region the bucket lives in (e.g. `us-east-1`). Falls back to * `AWS_REGION`; required if no env var is set. */ region?: string; /** * Override the S3 service endpoint. Use this to point at S3-compatible * services (DigitalOcean Spaces, Wasabi, Backblaze B2, LocalStack, etc.). */ endpoint?: string; /** * Use path-style addressing (`https://endpoint/bucket/key`) instead of * virtual-hosted style (`https://bucket.endpoint/key`). Required by some * S3-compatible services and by LocalStack. */ forcePathStyle?: boolean; /** * Static credentials. Skip to use the AWS credential chain (env vars, * IAM role, shared profile, EC2/ECS/EKS instance metadata). */ 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; } export 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. */ export declare const mapS3Error: (err: unknown, messages?: Partial>) => FilesError; export declare const s3: (opts: S3AdapterOptions) => S3Adapter; //# sourceMappingURL=index.d.ts.map