lean-s3
Version:
A server-side S3 API for the regular user.
683 lines (674 loc) • 30.1 kB
TypeScript
import { Readable } from 'node:stream';
import { Dispatcher } from 'undici';
/**
* @internal Normally, we'd use an interface for that, but having a class with pre-defined fields makes it easier for V8 top optimize hidden classes.
*/
declare class S3BucketEntry {
readonly key: string;
readonly size: number;
readonly lastModified: Date;
readonly etag: string;
readonly storageClass: StorageClass;
readonly checksumAlgorithm: ChecksumAlgorithm | undefined;
readonly checksumType: ChecksumType | undefined;
constructor(key: string, size: number, lastModified: Date, etag: string, storageClass: StorageClass, checksumAlgorithm: ChecksumAlgorithm | undefined, checksumType: ChecksumType | undefined);
/**
* @internal
*/
static parse(source: any): S3BucketEntry;
}
declare const __brand: unique symbol;
type Brand<B> = {
[__brand]: B;
};
type Branded<T, B> = T & Brand<B>;
type BucketName = Branded<string, "BucketName">;
type ObjectKey = Branded<string, "ObjectKey">;
type Endpoint = Branded<string, "Endpoint">;
type Region = Branded<string, "Region">;
declare const kWrite: unique symbol;
declare const kStream: unique symbol;
declare const kSignedRequest: unique symbol;
declare const kGetEffectiveParams: unique symbol;
interface S3ClientOptions {
/**
* The name of the bucket to operate on.
* Different S3 providers have different limitations here. All of them require:
* - Must be at least 3 characters long
* - Must be at most 63 characters long
* - Must not start or end with a period (.)
* - Must not contain two adjacent periods (..)
* - Must only contain lowercase letters, numbers, periods (.), and hyphens (-).
*/
bucket: string;
/**
* The region of the S3 bucket.
* This value is required for all S3 proviers. However, some providers don't care about its actual value.
*/
region: string;
/**
* The endpoint of the S3 service.
* This is required for all S3 providers.
*
* The endpoint may contain placeholders for region and bucket, which will be replaced internally with the actual values on use.
*
* For example, `https://{bucket}.s3.{region}.example.com` will be replaced with `https://my-bucket.s3.us-west-2.example.com` if the bucket is `my-bucket` and the region is `us-west-2`.
*
* If the endpoint does not contain a placeholder for the bucket, it will be appended to the path of the endpoint.
*/
endpoint: string;
/**
* The access key ID to use for authentication.
* This is required for all S3 providers.
*/
accessKeyId: string;
/**
* The secret access key to use for authentication.
* This is required for all S3 providers.
*/
secretAccessKey: string;
sessionToken?: string;
}
type OverridableS3ClientOptions = Partial<Pick<S3ClientOptions, "region" | "bucket" | "endpoint">>;
type CreateFileInstanceOptions = {
/** Content-Type of the file. */
type?: string;
};
type DeleteObjectsOptions = {
/** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
bucket?: string;
/** Signal to abort the request. */
signal?: AbortSignal;
};
type DeleteObjectsResult = {
errors: DeleteObjectsError[];
};
type DeleteObjectsError = {
code: string;
key: string;
message: string;
versionId: string;
};
interface S3FilePresignOptions extends OverridableS3ClientOptions {
contentHash?: Buffer;
/** Seconds. */
expiresIn?: number;
method?: PresignableHttpMethod;
contentLength?: number;
storageClass?: StorageClass;
acl?: Acl;
/** `Content-Type` of the file. */
type?: string;
/**
* Headers to set on the response of the S3 service.
*/
response?: {
/**
* Used to set the file name that browsers display when downloading the file.
*
* @example
* ```js
* client.presign("foo.jpg", {
* response: {
* contentDisposition: {
* type: "attachment",
* filename: "download.jpg",
* },
* },
* });
* ```
*/
contentDisposition?: ContentDisposition;
};
}
type ListObjectsOptions = {
/** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
bucket?: string;
prefix?: string;
maxKeys?: number;
delimiter?: string;
startAfter?: string;
continuationToken?: string;
/** Signal to abort the request. */
signal?: AbortSignal;
};
type ListObjectsIteratingOptions = {
/** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
bucket?: string;
prefix?: string;
startAfter?: string;
/** Signal to abort the request. */
signal?: AbortSignal;
internalPageSize?: number;
};
type ListMultipartUploadsOptions = {
/** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
bucket?: string;
delimiter?: string;
keyMarker?: string;
maxUploads?: number;
prefix?: string;
uploadIdMarker?: string;
/** Signal to abort the request. */
signal?: AbortSignal;
};
type ListMultipartUploadsResult = {
/** Name of the bucket the operation was used upon. */
bucket?: string;
keyMarker?: string;
uploadIdMarker?: string;
nextKeyMarker?: string;
prefix?: string;
delimiter?: string;
nextUploadIdMarker?: string;
maxUploads?: number;
isTruncated?: boolean;
uploads: MultipartUpload[];
};
type MultipartUpload = {
checksumAlgorithm?: ChecksumAlgorithm;
checksumType?: ChecksumType;
initiated?: Date;
/**
* Key of the object for which the multipart upload was initiated.
* Length Constraints: Minimum length of 1.
*/
key?: string;
storageClass?: StorageClass;
/**
* Upload ID identifying the multipart upload.
*/
uploadId?: string;
};
type CreateMultipartUploadOptions = {
/** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
bucket?: string;
/** Signal to abort the request. */
signal?: AbortSignal;
};
type CreateMultipartUploadResult = {
/** Name of the bucket the multipart upload was created in. */
bucket: string;
key: string;
uploadId: string;
};
type AbortMultipartUploadOptions = {
/** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
bucket?: string;
/** Signal to abort the request. */
signal?: AbortSignal;
};
type CompleteMultipartUploadOptions = {
/** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
bucket?: string;
/** Signal to abort the request. */
signal?: AbortSignal;
};
type CompleteMultipartUploadResult = {
/** The URI that identifies the newly created object. */
location?: string;
/** Name of the bucket the multipart upload was created in. */
bucket?: string;
key?: string;
etag?: string;
/** The Base64 encoded, 32-bit `CRC32` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC32` checksum algorithm. */
checksumCRC32?: string;
/** The Base64 encoded, 32-bit `CRC32C` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC32C` checksum algorithm. */
checksumCRC32C?: string;
/** The Base64 encoded, 64-bit `CRC64NVME` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC64NVME` checksum algorithm. */
checksumCRC64NVME?: string;
/** The Base64 encoded, 160-bit `SHA1` checksum of the part. This checksum is present if the multipart upload request was created with the `SHA1` checksum algorithm. */
checksumSHA1?: string;
/** The Base64 encoded, 256-bit `SHA256` checksum of the part. This checksum is present if the multipart upload request was created with the `SHA256` checksum algorithm. */
checksumSHA256?: string;
/**
* The checksum type, which determines how part-level checksums are combined to create an object-level checksum for multipart objects.
* You can use this header as a data integrity check to verify that the checksum type that is received is the same checksum type that was specified during the `CreateMultipartUpload` request.
*/
checksumType?: ChecksumType;
};
type MultipartUploadPart = {
partNumber: number;
etag: string;
};
type UploadPartOptions = {
/** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
bucket?: string;
/** Signal to abort the request. */
signal?: AbortSignal;
};
type UploadPartResult = {
partNumber: number;
etag: string;
};
type ListPartsOptions = {
maxParts?: number;
partNumberMarker?: string;
/** Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
bucket?: string;
/** Signal to abort the request. */
signal?: AbortSignal;
};
type ListPartsResult = {
/** Name of the bucket. */
bucket: string;
key: string;
uploadId: string;
partNumberMarker?: string;
nextPartNumberMarker?: string;
maxParts?: number;
isTruncated: boolean;
parts: Array<{
/** The Base64 encoded, 32-bit `CRC32` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC32` checksum algorithm. */
checksumCRC32?: string;
/** The Base64 encoded, 32-bit `CRC32C` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC32C` checksum algorithm. */
checksumCRC32C?: string;
/** The Base64 encoded, 64-bit `CRC64NVME` checksum of the part. This checksum is present if the multipart upload request was created with the `CRC64NVME` checksum algorithm. */
checksumCRC64NVME?: string;
/** The Base64 encoded, 160-bit `SHA1` checksum of the part. This checksum is present if the multipart upload request was created with the `SHA1` checksum algorithm. */
checksumSHA1?: string;
/** The Base64 encoded, 256-bit `SHA256` checksum of the part. This checksum is present if the multipart upload request was created with the `SHA256` checksum algorithm. */
checksumSHA256?: string;
etag: string;
lastModified: Date;
partNumber: number;
size: number;
}>;
storageClass?: StorageClass;
checksumAlgorithm?: ChecksumAlgorithm;
checksumType?: ChecksumType;
};
type ListObjectsResult = {
name: string;
prefix: string | undefined;
startAfter: string | undefined;
isTruncated: boolean;
continuationToken: string | undefined;
maxKeys: number;
keyCount: number;
nextContinuationToken: string | undefined;
contents: readonly S3BucketEntry[];
};
type BucketCreationOptions = {
/** Set this to override the {@link S3ClientOptions#endpoint} that was passed on creation of the {@link S3Client}. */
endpoint?: string;
/** Set this to override the {@link S3ClientOptions#region} that was passed on creation of the {@link S3Client}. */
region?: string;
locationConstraint?: string;
location?: BucketLocationInfo;
info?: BucketInfo;
/** Signal to abort the request. */
signal?: AbortSignal;
};
type BucketDeletionOptions = {
/** Signal to abort the request. */
signal?: AbortSignal;
};
type BucketExistsOptions = {
/** Signal to abort the request. */
signal?: AbortSignal;
};
type BucketCorsRules = readonly BucketCorsRule[];
type BucketCorsRule = {
allowedMethods: readonly HttpMethod[];
/** One or more origins you want customers to be able to access the bucket from. */
allowedOrigins: readonly string[];
/** Headers that are specified in the `Access-Control-Request-Headers` header. These headers are allowed in a preflight `OPTIONS` request. */
allowedHeaders?: readonly string[];
/** One or more headers in the response that you want customers to be able to access from their applications. */
exposeHeaders?: readonly string[];
/** Unique identifier for the rule. The value cannot be longer than 255 characters. */
id?: string;
/** The time in seconds that your browser is to cache the preflight response for the specified resource. */
maxAgeSeconds?: number;
};
type PutBucketCorsOptions = {
/** The CORS rules to set on the bucket. Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
bucket?: string;
/** Signal to abort the request. */
signal?: AbortSignal;
};
type DeleteBucketCorsOptions = {
/** The name of the bucket to delete the CORS configuration for. Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
bucket?: string;
/** Signal to abort the request. */
signal?: AbortSignal;
};
type GetBucketCorsOptions = {
/** The name of the bucket to get the CORS configuration for. Set this to override the {@link S3ClientOptions#bucket} that was passed on creation of the {@link S3Client}. */
bucket?: string;
/** Signal to abort the request. */
signal?: AbortSignal;
};
type GetBucketCorsResult = {
rules: BucketCorsRule[];
};
/**
* A configured S3 bucket instance for managing files.
*
* @example
* ```js
* // Basic bucket setup
* const bucket = new S3Client({
* bucket: "my-bucket",
* accessKeyId: "key",
* secretAccessKey: "secret"
* });
* // Get file instance
* const file = bucket.file("image.jpg");
* await file.delete();
* ```
*/
declare class S3Client {
#private;
/**
* Create a new instance of an S3 bucket so that credentials can be managed from a single instance instead of being passed to every method.
*
* @param options The default options to use for the S3 client.
*/
constructor(options: S3ClientOptions);
/** @internal */
[kGetEffectiveParams](options: OverridableS3ClientOptions): [region: Region, endpoint: Endpoint, bucket: BucketName];
/**
* Creates an S3File instance for the given path.
*
* @param {string} path The path to the object in the bucket. Also known as [object key](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html).
* We recommend not using the following characters in a key name because of significant special character handling, which isn't consistent across all applications (see [AWS docs](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html)):
* - Backslash (`\\`)
* - Left brace (`{`)
* - Non-printable ASCII characters (128–255 decimal characters)
* - Caret or circumflex (`^`)
* - Right brace (`}`)
* - Percent character (`%`)
* - Grave accent or backtick (`\``)
* - Right bracket (`]`)
* - Quotation mark (`"`)
* - Greater than sign (`>`)
* - Left bracket (`[`)
* - Tilde (`~`)
* - Less than sign (`<`)
* - Pound sign (`#`)
* - Vertical bar or pipe (`|`)
*
* lean-s3 does not enforce these restrictions.
*
* @example
* ```js
* const file = client.file("image.jpg");
* await file.write(imageData);
*
* const configFile = client.file("config.json", {
* type: "application/json",
* });
* ```
*/
file(path: string, options?: CreateFileInstanceOptions): S3File;
/**
* Generate a presigned URL for temporary access to a file.
* Useful for generating upload/download URLs without exposing credentials.
* @returns The operation on {@link S3Client#presign.path} as a pre-signed URL.
*
* @example
* ```js
* const downloadUrl = client.presign("file.pdf", {
* expiresIn: 3600 // 1 hour
* });
* ```
*
* @example
* ```js
* client.presign("foo.jpg", {
* expiresIn: 3600 // 1 hour
* response: {
* contentDisposition: {
* type: "attachment",
* filename: "download.jpg",
* },
* },
* });
* ```
*/
presign(path: string, options?: S3FilePresignOptions): string;
createMultipartUpload(key: string, options?: CreateMultipartUploadOptions): Promise<CreateMultipartUploadResult>;
/**
* @remarks Uses [`ListMultipartUploads`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListMultipartUploads.html).
* @throws {RangeError} If `options.maxKeys` is not between `1` and `1000`.
*/
listMultipartUploads(options?: ListMultipartUploadsOptions): Promise<ListMultipartUploadsResult>;
/**
* @remarks Uses [`AbortMultipartUpload`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_AbortMultipartUpload.html).
* @throws {RangeError} If `key` is not at least 1 character long.
* @throws {Error} If `uploadId` is not provided.
*/
abortMultipartUpload(path: string, uploadId: string, options?: AbortMultipartUploadOptions): Promise<void>;
/**
* @remarks Uses [`CompleteMultipartUpload`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html).
* @throws {RangeError} If `key` is not at least 1 character long.
* @throws {Error} If `uploadId` is not provided.
*/
completeMultipartUpload(path: string, uploadId: string, parts: readonly MultipartUploadPart[], options?: CompleteMultipartUploadOptions): Promise<CompleteMultipartUploadResult>;
/**
* @remarks Uses [`UploadPart`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html).
* @throws {RangeError} If `key` is not at least 1 character long.
* @throws {Error} If `uploadId` is not provided.
*/
uploadPart(path: string, uploadId: string, data: string | Buffer | Uint8Array | Readable, partNumber: number, options?: UploadPartOptions): Promise<UploadPartResult>;
/**
* @remarks Uses [`ListParts`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html).
* @throws {RangeError} If `key` is not at least 1 character long.
* @throws {Error} If `uploadId` is not provided.
* @throws {TypeError} If `options.maxParts` is not a `number`.
* @throws {RangeError} If `options.maxParts` is <= 0.
* @throws {TypeError} If `options.partNumberMarker` is not a `string`.
*/
listParts(path: string, uploadId: string, options?: ListPartsOptions): Promise<ListPartsResult>;
/**
* Creates a new bucket on the S3 server.
*
* @param name The name of the bucket to create. AWS the name according to [some rules](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html). The most important ones are:
* - Bucket names must be between `3` (min) and `63` (max) characters long.
* - Bucket names can consist only of lowercase letters, numbers, periods (`.`), and hyphens (`-`).
* - Bucket names must begin and end with a letter or number.
* - Bucket names must not contain two adjacent periods.
* - Bucket names must not be formatted as an IP address (for example, `192.168.5.4`).
*
* @throws {Error} If the bucket name is invalid.
* @throws {S3Error} If the bucket could not be created, e.g. if it already exists.
* @remarks Uses [`CreateBucket`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html)
*/
createBucket(name: string, options?: BucketCreationOptions): Promise<void>;
/**
* Deletes a bucket from the S3 server.
* @param name The name of the bucket to delete. Same restrictions as in {@link S3Client#createBucket}.
* @throws {Error} If the bucket name is invalid.
* @throws {S3Error} If the bucket could not be deleted, e.g. if it is not empty.
* @remarks Uses [`DeleteBucket`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucket.html).
*/
deleteBucket(name: string, options?: BucketDeletionOptions): Promise<void>;
/**
* Checks if a bucket exists.
* @param name The name of the bucket to delete. Same restrictions as in {@link S3Client#createBucket}.
* @throws {Error} If the bucket name is invalid.
* @remarks Uses [`HeadBucket`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadBucket.html).
*/
bucketExists(name: string, options?: BucketExistsOptions): Promise<boolean>;
/**
* @remarks Uses [`PutBucketCors`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketCors.html).
*/
putBucketCors(rules: BucketCorsRules, options?: PutBucketCorsOptions): Promise<void>;
/**
* @remarks Uses [`GetBucketCors`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketCors.html).
*/
getBucketCors(options?: GetBucketCorsOptions): Promise<GetBucketCorsResult>;
/**
* @remarks Uses [`DeleteBucketCors`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketCors.html).
*/
deleteBucketCors(options?: DeleteBucketCorsOptions): Promise<void>;
/**
* Uses [`ListObjectsV2`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html) to iterate over all keys. Pagination and continuation is handled internally.
*/
listIterating(options: ListObjectsIteratingOptions): AsyncGenerator<S3BucketEntry>;
/**
* Implements [`ListObjectsV2`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html) to iterate over all keys.
*
* @throws {RangeError} If `maxKeys` is not between `1` and `1000`.
*/
list(options?: ListObjectsOptions): Promise<ListObjectsResult>;
/**
* Uses [`DeleteObjects`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html) to delete multiple objects in a single request.
*/
deleteObjects(objects: readonly S3BucketEntry[] | readonly string[], options?: DeleteObjectsOptions): Promise<DeleteObjectsResult>;
/**
* Do not use this. This is an internal method.
* TODO: Maybe move this into a separate free function?
* @internal
*/
[kSignedRequest](region: Region, endpoint: Endpoint, bucket: BucketName, method: HttpMethod, pathWithoutBucket: ObjectKey, query: string | undefined, body: string | Buffer | Uint8Array | Readable | undefined, additionalSignedHeaders: Record<string, string> | undefined, additionalUnsignedHeaders: Record<string, string> | undefined, contentHash: Buffer | undefined, signal: AbortSignal | undefined): Promise<Dispatcher.ResponseData<null>>;
/** @internal */
[kWrite](path: ObjectKey, data: string | Buffer | Uint8Array | Readable, contentType: string, contentLength: number | undefined, contentHash: Buffer | undefined, rageStart: number | undefined, rangeEndExclusive: number | undefined, signal?: AbortSignal | undefined): Promise<void>;
/**
* @internal
*/
[kStream](path: ObjectKey, contentHash: Buffer | undefined, rageStart: number | undefined, rangeEndExclusive: number | undefined): ReadableStream<Uint8Array>;
}
declare class S3Stat {
readonly etag: string;
readonly lastModified: Date;
readonly size: number;
readonly type: string;
constructor(etag: string, lastModified: Date, size: number, type: string);
static tryParseFromHeaders(headers: Record<string, string | string[] | undefined>): S3Stat | undefined;
}
declare class S3File {
#private;
/** @internal */
constructor(client: S3Client, path: ObjectKey, start: number | undefined, end: number | undefined, contentType: string | undefined);
/**
* Creates and returns a new {@link S3File} containing a subset of this {@link S3File} data.
* @param start The starting index.
* @param end The ending index, exclusive.
*/
slice(start?: number, end?: number): S3File;
/**
* Creates and returns a new {@link S3File} containing a subset of this {@link S3File} data.
* @param start The starting index.
* @param end The ending index, exclusive.
* @param contentType The content-type for the new {@link S3File}.
*/
slice(start?: number, end?: number, contentType?: string): S3File;
/**
* Get the stat of a file in the bucket. Uses `HEAD` request to check existence.
*
* @remarks Uses [`HeadObject`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html).
* @throws {S3Error} If the file does not exist or the server has some other issues.
* @throws {Error} If the server returns an invalid response.
*/
stat(options?: S3StatOptions): Promise<S3Stat>;
/**
* Check if a file exists in the bucket. Uses `HEAD` request to check existence.
*
* @remarks Uses [`HeadObject`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html).
*/
exists(options?: S3FileExistsOptions): Promise<boolean>;
/**
* Delete a file from the bucket.
*
* @remarks - Uses [`DeleteObject`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html).
* - `versionId` not supported.
*
* @param {S3FileDeleteOptions} [options]
*
* @example
* ```js
* // Simple delete
* await client.delete("old-file.txt");
*
* // With error handling
* try {
* await client.delete("file.dat");
* console.log("File deleted");
* } catch (err) {
* console.error("Delete failed:", err);
* }
* ```
*/
delete(options?: S3FileDeleteOptions): Promise<void>;
toString(): string;
json(): Promise<unknown>;
bytes(): Promise<Uint8Array>;
arrayBuffer(): Promise<ArrayBuffer>;
text(): Promise<string>;
blob(): Promise<Blob>;
stream(): ReadableStream<Uint8Array>;
/**
* @param {ByteSource} data
* @param {S3FileWriteOptions} [options.type] Defaults to the Content-Type that was used to create the {@link S3File} instance.
* @returns {Promise<void>}
*/
write(data: ByteSource, options?: S3FileWriteOptions): Promise<void>;
}
interface S3FileDeleteOptions extends OverridableS3ClientOptions {
/** Signal to abort the request. */
signal?: AbortSignal;
}
interface S3StatOptions extends OverridableS3ClientOptions {
/** Signal to abort the request. */
signal?: AbortSignal;
}
interface S3FileExistsOptions extends OverridableS3ClientOptions {
/** Signal to abort the request. */
signal?: AbortSignal;
}
type S3FileWriteOptions = {
/** Content-Type of the file. */
type?: string;
/** Signal to abort the request. */
signal?: AbortSignal;
};
declare class S3Error extends Error {
readonly code: string;
readonly path: string;
readonly message: string;
readonly requestId: string | undefined;
readonly hostId: string | undefined;
constructor(code: string, path: string, { message, requestId, hostId, cause, }?: S3ErrorOptions);
}
type S3ErrorOptions = {
message?: string | undefined;
requestId?: string | undefined;
hostId?: string | undefined;
cause?: unknown;
};
type Acl = "private" | "public-read" | "public-read-write" | "aws-exec-read" | "authenticated-read" | "bucket-owner-read" | "bucket-owner-full-control" | "log-delivery-write";
type StorageClass = "STANDARD" | "DEEP_ARCHIVE" | "EXPRESS_ONEZONE" | "GLACIER" | "GLACIER_IR" | "INTELLIGENT_TIERING" | "ONEZONE_IA" | "OUTPOSTS" | "REDUCED_REDUNDANCY" | "SNOW" | "STANDARD_IA";
type ChecksumAlgorithm = "CRC32" | "CRC32C" | "CRC64NVME" | "SHA1" | "SHA256";
type ChecksumType = "COMPOSITE" | "FULL_OBJECT";
type PresignableHttpMethod = "GET" | "DELETE" | "PUT" | "HEAD";
type HttpMethod = PresignableHttpMethod | "POST";
type ByteSource = string | Buffer | Uint8Array | Readable | Blob;
/**
* Implements [LocationInfo](https://docs.aws.amazon.com/AmazonS3/latest/API/API_LocationInfo.html)
*/
type BucketLocationInfo = {
name?: string;
type?: string;
};
/**
* Implements [BucketInfo](https://docs.aws.amazon.com/AmazonS3/latest/API/API_BucketInfo.html)
*/
type BucketInfo = {
dataRedundancy?: string;
type?: string;
};
/**
* Represents valid values for the [`Content-Disposition`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Disposition) header.
*/
type ContentDisposition = AttachmentContentDisposition | InlineContentDisposition;
type InlineContentDisposition = {
type: "inline";
};
type AttachmentContentDisposition = {
type: "attachment";
filename?: string;
};
export { type AbortMultipartUploadOptions, type Acl, type AttachmentContentDisposition, type BucketCorsRule, type BucketCorsRules, type BucketCreationOptions, type BucketDeletionOptions, type BucketExistsOptions, type BucketInfo, type BucketLocationInfo, type ByteSource, type ChecksumAlgorithm, type ChecksumType, type CompleteMultipartUploadOptions, type CompleteMultipartUploadResult, type ContentDisposition, type CreateFileInstanceOptions, type CreateMultipartUploadOptions, type CreateMultipartUploadResult, type DeleteBucketCorsOptions, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, type GetBucketCorsOptions, type GetBucketCorsResult, type HttpMethod, type InlineContentDisposition, type ListMultipartUploadsOptions, type ListMultipartUploadsResult, type ListObjectsIteratingOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListPartsResult, type MultipartUpload, type MultipartUploadPart, type OverridableS3ClientOptions, type PresignableHttpMethod, type PutBucketCorsOptions, S3BucketEntry, S3Client, type S3ClientOptions, S3Error, type S3ErrorOptions, S3File, type S3FileDeleteOptions, type S3FileExistsOptions, type S3FilePresignOptions, type S3FileWriteOptions, S3Stat, type S3StatOptions, type StorageClass, type UploadPartOptions, type UploadPartResult };