do-spaces
Version:
Unofficial package for simple managing file operations hosted on "Digital Ocean Spaces" written in Typescript
64 lines (63 loc) • 2.41 kB
TypeScript
/// <reference types="node" />
import AWS, { S3 } from 'aws-sdk';
declare type AwsParam = {
[key: string]: any;
};
export declare type Privacy = 'private' | 'public-read';
export declare type Credentials = {
endpoint: string;
accessKey: string;
secret: string;
bucket: string;
};
export declare type ListFiles = {
maxFiles?: number;
path: string;
nextMarker?: string;
awsParams?: AwsParam;
};
export declare type UploadFile = {
pathname: string;
privacy: Privacy;
file: Blob | BinaryType | string | Buffer;
awsParams?: AwsParam;
};
export declare type CopyFile = {
pathname: string;
copiedPathname: string;
privacy: Privacy;
fromBucket?: string;
awsParams?: AwsParam;
};
export declare type FolderParam = {
path: string;
awsParams?: AwsParam;
};
export declare type FileParam = {
pathname: string;
awsParams?: AwsParam;
};
export declare type DeleteFolder = {
path: string;
awsListParams?: AwsParam;
awsDeleteParams?: AwsParam;
};
export declare class Spaces {
s3: S3;
bucket: string;
endpoint: string;
constructor({ endpoint, accessKey, secret, bucket }: Credentials);
private _removeLeadingSlash;
private _getContentTypeFromExtension;
createFolder({ path, awsParams }: FolderParam): Promise<import("aws-sdk/lib/request").PromiseResult<S3.PutObjectOutput, AWS.AWSError>>;
/**
* Removed all files inside folder
*/
deleteFolder({ path, awsListParams, awsDeleteParams, }: DeleteFolder): Promise<any>;
downloadFile({ pathname, awsParams }: FileParam): Promise<import("aws-sdk/lib/request").PromiseResult<S3.GetObjectOutput, AWS.AWSError>>;
listFiles({ maxFiles, path, nextMarker, awsParams, }: ListFiles): Promise<import("aws-sdk/lib/request").PromiseResult<S3.ListObjectsOutput, AWS.AWSError>>;
uploadFile({ pathname, privacy, file, awsParams }: UploadFile): Promise<import("aws-sdk/lib/request").PromiseResult<S3.PutObjectOutput, AWS.AWSError>>;
copyFile({ pathname, copiedPathname, privacy, fromBucket, awsParams, }: CopyFile): Promise<import("aws-sdk/lib/request").PromiseResult<S3.CopyObjectOutput, AWS.AWSError>>;
deleteFile({ pathname, awsParams }: FileParam): Promise<import("aws-sdk/lib/request").PromiseResult<S3.DeleteObjectOutput, AWS.AWSError>>;
}
export default Spaces;