s3-batch-upload
Version:
Super fast batched S3 folder uploads from CLI or API.
52 lines (51 loc) • 1.82 kB
TypeScript
import S3 from 'aws-sdk/clients/s3';
import { ConfigurationOptions } from 'aws-sdk/lib/config';
export declare type Options = {
bucket: string;
localPath: string;
remotePath: string;
config?: string | ConfigurationOptions;
glob?: string;
globOptions?: object;
concurrency?: number;
dryRun?: boolean;
cacheControl?: string | {
[key: string]: string;
};
s3Client?: S3;
accessControlLevel?: S3.ObjectCannedACL;
overwrite?: boolean;
};
export default class Uploader {
private s3;
private options;
private bar;
constructor(options: Options);
/**
* Executes the upload operation based on the provided options in the Uploader constructor.
* @returns A list of paths of the upload files relative to the bucket.
*/
upload(): Promise<string[]>;
private run();
/**
* Based on the local path and the provided glob pattern, this util function will find all relevant
* files, which will be used to upload in another step.
* @returns A list of resolved files based on the glob pattern
*/
private getFiles();
/**
* Uploads a single file to S3 from the local to the remote path with the available options,
* and returns the uploaded location.
*
* @param localFilePath Path to the local file, either relative to cwd, or absolute
* @param remotePath The path to upload the file to in the bucket
* @returns The remote path upload location relative to the bucket
*/
uploadFile(localFilePath: string, remotePath: string): Promise<string>;
/**
*
* @param file Path to a local file, either relative to cwd, or absolute
* @return The resolved CacheControl value based on the provided settings
*/
getCacheControlValue(file: string): string;
}