///
///
///
import { Readable } from 'node:stream';
import { IncomingMessage } from 'node:http';
import { S3, GetObjectCommandInput, PutObjectCommandInput, DeleteObjectCommandInput, ListObjectsCommandInput, GetObjectCommandOutput, PutObjectCommandOutput, DeleteObjectCommandOutput, ListObjectsCommandOutput } from '@aws-sdk/client-s3';
export type NodeJsRuntimeStreamingBlobPayloadOutputTypes = SdkStream;
export type SdkStream = BaseStream & SdkStreamMixin;
export interface SdkStreamMixin {
transformToByteArray: () => Promise;
transformToString: (encoding?: string) => Promise;
transformToWebStream: () => ReadableStream;
}
export interface ResponseMetadata {
/**
* The status code of the last HTTP response received for this operation.
*/
httpStatusCode?: number;
/**
* A unique identifier for the last request sent for this operation. Often
* requested by AWS service teams to aid in debugging.
*/
requestId?: string;
/**
* A secondary identifier for the last request sent. Used for debugging.
*/
extendedRequestId?: string;
/**
* A tertiary identifier for the last request sent. Used for debugging.
*/
cfId?: string;
/**
* The number of times this operation was attempted.
*/
attempts?: number;
/**
* The total amount of time (in milliseconds) that was spent waiting between
* retry attempts.
*/
totalRetryDelay?: number;
}
export interface ExtendGetObjectCommandOutput extends GetObjectCommandOutput {
Body: NodeJsRuntimeStreamingBlobPayloadOutputTypes;
$metadata: ResponseMetadata;
}
export interface ExtendPutObjectCommandOutput extends PutObjectCommandOutput {
$metadata: ResponseMetadata;
}
export interface ExtendDeleteObjectCommandOutput extends DeleteObjectCommandOutput {
$metadata: ResponseMetadata;
}
export interface ExtendListObjectsCommandOutput extends ListObjectsCommandOutput {
$metadata: ResponseMetadata;
}
/**
* `ICloudStorage` is an interface for cloud storage services.
*/
export declare class CloudStorage {
protected _externalS3Client: S3;
protected _internalS3Client: S3;
protected get appid(): string;
get externalEndpoint(): string;
get internalEndpoint(): string;
/**
* Get external S3 client of `@aws-sdk/client-s3`.
* You can use this client to access the bucket through the external endpoint.
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/s3/
* @returns
*/
getExternalS3Client(): S3;
/**
* Get internal S3 client of `@aws-sdk/client-s3`.
* You can use this client to access the bucket through the internal endpoint.
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/s3/
*/
getInternalS3Client(): S3;
/**
* Get bucket by bucket name
* @returns
*/
bucket(bucketName: string): CloudStorageBucket;
}
export declare class CloudStorageBucket {
protected readonly storage: CloudStorage;
readonly name: string;
constructor(storage: CloudStorage, name: string);
/**
* Read file from bucket
* @param filename filename is the key of the object, it can contain subdirectories, e.g. `a/b/c.txt`
* @param options
* @returns
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html
*/
readFile(filename: string, options?: Omit): Promise;
/**
* Write file to bucket
* @param filename filename is the key of the object, it can contain subdirectories, e.g. `a/b/c.txt`
* @param body body is the content of the object, it can be a string, a Buffer, a Readable stream, or a Blob
* @param options
* @returns
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html
*/
writeFile(filename: string, body: string | Blob | Buffer | Uint8Array | Readable, options?: Omit): Promise;
/**
* Delete file from bucket
* @param filename filename is the key of the object, it can contain subdirectories, e.g. `a/b/c.txt`
* @param options
* @returns
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html
*/
deleteFile(filename: string, options?: Omit): Promise;
/**
* List files in bucket
* @param prefix prefix is the key prefix of the object, it can contain subdirectories, e.g. `a/b/`
* @param options
* @returns
* @see https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjects.html
*/
listFiles(options?: Omit): Promise;
/**
* Get external url of the file.
* You can ONLY use this url to access file from `readonly` bucket or `public` bucket.
* Use `getDownloadUrl()` to get a signed url for `private` bucket.
* @param filename filename is the key of the object, it can contain subdirectories, e.g. `a/b/c.txt`
* @returns
*/
externalUrl(filename: string): string;
/**
* Get internal url of the file.
* You can ONLY use this url to access file from `readonly` bucket or `public` bucket.
* Use `getDownloadUrl()` to get a signed url for `private` bucket.
* @param filename filename is the key of the object, it can contain subdirectories, e.g. `a/b/c.txt`
* @returns
*/
internalUrl(filename: string): string;
/**
* Get upload url, you can use this url to upload file directly to bucket
* @param filename filename is the key of the object, it can contain subdirectories, e.g. `a/b/c.txt`
* @param expiresIn expiresIn is the seconds of the signed url, default is `3600` seconds which is 1 hour
* @param options
* @returns
*/
getUploadUrl(filename: string, expiresIn?: number, options?: Omit): Promise;
/**
* Get download url, you can use this url to download file directly from bucket
* @param filename filename is the key of the object, it can contain subdirectories, e.g. `a/b/c.txt`
* @param expiresIn expiresIn is the seconds of the signed url, default is `3600` seconds which is 1 hour
* @param options
* @returns
*/
getDownloadUrl(filename: string, expiresIn?: number, options?: Omit): Promise;
}
//# sourceMappingURL=storage.d.ts.map