UNPKG

@push.rocks/smartbucket

Version:

A TypeScript library providing a cloud-agnostic interface for managing object storage with functionalities like bucket management, file and directory operations, and advanced features such as metadata handling and file locking.

113 lines (112 loc) 3.6 kB
import * as plugins from './plugins.js'; import * as interfaces from './interfaces.js'; import { SmartBucket } from './classes.smartbucket.js'; import { Directory } from './classes.directory.js'; import { File } from './classes.file.js'; import { Trash } from './classes.trash.js'; /** * The bucket class exposes the basic functionality of a bucket. * The functions of the bucket alone are enough to * operate in S3 basic fashion on blobs of data. */ export declare class Bucket { static getBucketByName(smartbucketRef: SmartBucket, bucketNameArg: string): Promise<Bucket>; static createBucketByName(smartbucketRef: SmartBucket, bucketName: string): Promise<Bucket>; static removeBucketByName(smartbucketRef: SmartBucket, bucketName: string): Promise<void>; smartbucketRef: SmartBucket; name: string; constructor(smartbucketRef: SmartBucket, bucketName: string); /** * gets the base directory of the bucket */ getBaseDirectory(): Promise<Directory>; /** * gets the trash directory */ getTrash(): Promise<Trash>; getDirectoryFromPath(pathDescriptorArg: interfaces.IPathDecriptor): Promise<Directory>; /** * store file */ fastPut(optionsArg: interfaces.IPathDecriptor & { contents: string | Buffer; overwrite?: boolean; }): Promise<File | null>; fastPutStrict(...args: Parameters<Bucket['fastPut']>): Promise<File>; /** * get file */ fastGet(optionsArg: { path: string; }): Promise<Buffer>; /** * good when time to first byte is important * and multiple subscribers are expected * @param optionsArg * @returns */ fastGetReplaySubject(optionsArg: { path: string; }): Promise<plugins.smartrx.rxjs.ReplaySubject<Buffer>>; fastGetStream(optionsArg: { path: string; }, typeArg: 'webstream'): Promise<ReadableStream>; fastGetStream(optionsArg: { path: string; }, typeArg: 'nodestream'): Promise<plugins.stream.Readable>; /** * store file as stream */ fastPutStream(optionsArg: { path: string; readableStream: plugins.stream.Readable | ReadableStream; nativeMetadata?: { [key: string]: string; }; overwrite?: boolean; }): Promise<void>; fastCopy(optionsArg: { sourcePath: string; destinationPath?: string; targetBucket?: Bucket; nativeMetadata?: { [key: string]: string; }; deleteExistingNativeMetadata?: boolean; }): Promise<void>; /** * Move object from one path to another within the same bucket or to another bucket */ fastMove(optionsArg: { sourcePath: string; destinationPath: string; targetBucket?: Bucket; overwrite?: boolean; }): Promise<void>; /** * removeObject */ fastRemove(optionsArg: { path: string; }): Promise<void>; /** * check whether file exists * @param optionsArg * @returns */ fastExists(optionsArg: { path: string; }): Promise<boolean>; /** * deletes this bucket */ delete(): Promise<void>; fastStat(pathDescriptor: interfaces.IPathDecriptor): Promise<plugins.s3.HeadObjectCommandOutput>; isDirectory(pathDescriptor: interfaces.IPathDecriptor): Promise<boolean>; isFile(pathDescriptor: interfaces.IPathDecriptor): Promise<boolean>; getMagicBytes(optionsArg: { path: string; length: number; }): Promise<Buffer>; cleanAllContents(): Promise<void>; }