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.

125 lines (124 loc) 3.57 kB
import * as plugins from './plugins.js'; import { Bucket } from './classes.bucket.js'; import { File } from './classes.file.js'; export declare class Directory { bucketRef: Bucket; parentDirectoryRef: Directory; name: string; tree: string[]; files: string[]; folders: string[]; constructor(bucketRefArg: Bucket, parentDirectory: Directory, name: string); /** * returns an array of parent directories */ getParentDirectories(): Directory[]; /** * returns the directory level */ getDirectoryLevel(): number; /** * updates the base path */ getBasePath(): string; /** * gets a file by name */ getFile(optionsArg: { path: string; createWithContents?: string | Buffer; getFromTrash?: boolean; }): Promise<File>; /** * Check if a file exists in this directory */ fileExists(optionsArg: { path: string; }): Promise<boolean>; /** * Check if a subdirectory exists */ directoryExists(dirNameArg: string): Promise<boolean>; /** * Collects all ListObjectsV2 pages for a prefix. */ private listObjectsV2AllPages; /** * lists all files */ listFiles(): Promise<File[]>; /** * lists all folders */ listDirectories(): Promise<Directory[]>; /** * gets an array that has all objects with a certain prefix */ getTreeArray(): Promise<plugins.s3._Object[] | undefined>; /** * gets a sub directory by name */ getSubDirectoryByName(dirNameArg: string, optionsArg?: { /** * in object storage a directory does not exist if it is empty * this option returns a directory even if it is empty */ getEmptyDirectory?: boolean; /** * in object storage a directory does not exist if it is empty * this option creates a directory even if it is empty using a initializer file */ createWithInitializerFile?: boolean; /** * if the path is a file path, it will be treated as a file and the parent directory will be returned */ couldBeFilePath?: boolean; }): Promise<Directory>; /** * moves the directory */ move(): Promise<void>; /** * creates an empty file within this directory * @param relativePathArg */ createEmptyFile(relativePathArg: string): Promise<File>; fastPut(optionsArg: { path: string; contents: string | Buffer; }): Promise<void>; fastGet(optionsArg: { path: string; }): Promise<Buffer<ArrayBufferLike>>; fastGetStream(optionsArg: { path: string; }, typeArg: 'webstream'): Promise<ReadableStream>; fastGetStream(optionsArg: { path: string; }, typeArg: 'nodestream'): Promise<plugins.stream.Readable>; /** * fast put stream */ fastPutStream(optionsArg: { path: string; stream: plugins.stream.Readable; }): Promise<void>; /** * removes a file within the directory * uses file class to make sure effects for metadata etc. are handled correctly * @param optionsArg */ fastRemove(optionsArg: { path: string; /** * wether the file should be placed into trash. Default is false. */ mode?: 'permanent' | 'trash'; }): Promise<void>; /** * deletes the directory with all its contents */ delete(optionsArg: { mode?: 'permanent' | 'trash'; }): Promise<void>; }