import { a as BucketFile, S as S3Auth, F as FileInfo, W as WriteContent, c as WriteOptions, B as Bucket, b as BucketInfo } from '../types-ANca2IFa.js'; interface R2BucketContext { makeUrl: (path?: string) => string; doRequest: (method: string, path: string, options?: { body?: string | Buffer; headers?: Record; }) => Promise; getAuth: () => S3Auth; bucketName: string; url: string; /** Public base (r2.dev or custom domain) for publicUrl(); "" when unset. */ publicUrl: string; prefix: string; } declare class R2File implements BucketFile { #private; name: string; path: string; constructor(path: string, ctx: R2BucketContext); slice(start: number, end?: number): R2File; info(): Promise; exists(): Promise; text(): Promise; json(): Promise; arrayBuffer(): Promise; blob(): Promise; bytes(): Promise; write(content: WriteContent, options?: WriteOptions): Promise; copyTo(dest: string | BucketFile): Promise; moveTo(dest: string | BucketFile): Promise; rename(name: string): Promise; remove(): Promise; unlink(): Promise; stream(): ReadableStream; nodeReadable(): NodeJS.ReadableStream; writable(options?: WriteOptions): WritableStream; nodeWritable(options?: WriteOptions): NodeJS.WritableStream; publicUrl(): Promise; signedUrl(opts: { expires: number | string; }): Promise; uploadUrl(opts: { expires: number | string; }): Promise; } interface R2Config { id?: string; secret?: string; region?: string; sessionToken?: string; /** Full R2 endpoint URL, including the bucket name at the end: * `https://.r2.cloudflarestorage.com/` (falls back to * `R2_URL`). */ url?: string; /** Public base for `file.publicUrl()`: the bucket's `r2.dev` or custom * domain, e.g. `https://cdn.example.com` (falls back to `R2_PUBLIC_URL`). * Without it `publicUrl()` returns null, since R2's storage endpoint is * never publicly readable. */ publicUrl?: string; } declare class CloudflareR2Bucket implements Bucket { #private; readonly type = "R2"; private url; private bucketName; PREFIX: string; constructor(name?: string, { id, secret, region, sessionToken, url, publicUrl, }?: R2Config); private makeUrl; private doRequest; info(): Promise; private pages; scan(filter?: RegExp): AsyncGenerator; list(filter?: RegExp): Promise; remove(filter?: RegExp): Promise; private handle; file(name: string): R2File; folder(path: string): CloudflareR2Bucket; count(filter?: RegExp): Promise; [Symbol.asyncIterator](): AsyncGenerator; } /** * Create a Cloudflare R2 bucket handle. * * @param name - Bucket name (falls back to `R2_BUCKET` env var) * @param config.id - Access Key ID (falls back to `R2_ACCESS_KEY_ID`) * @param config.secret - Secret Access Key (falls back to `R2_SECRET_ACCESS_KEY`) * @param config.sessionToken - Session token for temporary credentials (falls back to `R2_SESSION_TOKEN`) * @param config.region - Region, default `"auto"` (falls back to `R2_REGION`) * @param config.url - Full R2 endpoint URL, including the bucket name at the end: * `https://.r2.cloudflarestorage.com/` (falls back to `R2_URL`) * * @example * const bucket = CloudflareR2("my-bucket", { * id: "keyId", * secret: "secretKey", * url: "https://abc.r2.cloudflarestorage.com/my-bucket", * }); * await bucket.file("hello.txt").write("hello"); */ declare function CloudflareR2(name?: string, config?: R2Config): CloudflareR2Bucket; export { Bucket, BucketFile, BucketInfo, FileInfo, type R2Config, WriteContent, WriteOptions, CloudflareR2 as default };