import * as fs from 'node:fs'; import { Readable } from 'node:stream'; import { Logger } from '@nestjs/common'; import { FileTypeResult } from 'file-type'; import { CopyFileOptionsType, CopyOrMoveInputInterface, CopyReturnType, DeleteFileOptionsType, DeleteReturnType, DoesFileExistOptionsType, GetFileStatsOptionsType, GetFileStatsReturnType, GetFileStreamLocalOptionsInterface, GetFileStreamOptionsType, GetFileStreamReturnType, GetFilesCursorOptions, GetFilesCursorReturnType, GetOptionsType, MoveFileOptionsType, MoveReturnType, StorageProvidersType, UploadFileLocalOptionsInterface, UploadFileOptionsType, UploadReturnType } from '../interface'; import { FileType } from '../type'; export declare abstract class AbstractStorage { private readonly storageOptions; protected readonly logger: Logger; protected static defaultUploadOptions: UploadFileLocalOptionsInterface; protected static defaultGetFilesCursorOptions: { perPage: number; }; protected constructor(storageOptions: StorageProvidersType); /** * Returns options which were passed to `register` or `registerAsync` method. */ abstract get options(): GetOptionsType; /** * Uploads a file to the storage. */ abstract upload(file: FileType, options?: UploadFileOptionsType): Promise; /** * Uploads multiple files to the storage. * Equivalent to * @example Promise.allSettled(this.storage.upload(file), this.storage.upload(file)) */ abstract uploadMany(files: FileType[], options?: UploadFileLocalOptionsInterface): Promise[]>; /** * Deletes a file from the storage. */ abstract delete(path: string, options?: DeleteFileOptionsType): Promise; /** * Deletes multiple files from the storage. * Equivalent to * @example Promise.allSettled(this.storage.delete(relativeFilePath), this.storage.delete(relativeFilePath)) */ abstract deleteMany(paths: string[], options?: DeleteFileOptionsType): Promise[]>; /** * Checks if a file exists in the storage. * Returns `true` if the file exists, otherwise `false`. */ abstract doesFileExist(path: string, options?: DoesFileExistOptionsType): Promise; /** * Checks if multiple files exist in the storage. * Equivalent to * @example Promise.allSettled(this.storage.doesFileExist(relativeFilePath), this.storage.doesFileExist(relativeFilePath)) */ abstract doesFileExistMany(paths: string[], options?: DoesFileExistOptionsType): Promise[]>; /** * Returns an async generator that yields file stats for each file in the storage. */ abstract getFilesCursor(options?: GetFilesCursorOptions): GetFilesCursorReturnType; /** * Returns file stats for a file. */ abstract getFileStats(path: string, options?: GetFileStatsOptionsType): Promise; /** * Copy a file to provided destination. * It can only copy to a same storage path. */ abstract copy(input: CopyOrMoveInputInterface, options?: CopyFileOptionsType): Promise; /** * Copies multiple files to provided paths * Equivalent to * @example Promise.allSettled(this.storage.copy(relativePath), this.storage.copy(relativePath)) */ abstract copyMany(input: CopyOrMoveInputInterface[]): Promise[]>; /** * Moves a file to provided path. * Returns the relative path of the moved file. * It can only move to a same storage path. */ abstract move(input: CopyOrMoveInputInterface, options?: MoveFileOptionsType): Promise; /** * Moves multiple files to provided destinations. * Equivalent to * @example Promise.allSettled(this.storage.move(relativePath), this.storage.move(relativePath)) */ abstract moveMany(input: CopyOrMoveInputInterface[], options?: MoveFileOptionsType): Promise[]>; abstract getFile(path: string, options?: GetFileStreamOptionsType): Promise; protected getFileType(file: FileType): Promise<{ file: FileType; fileType: FileTypeResult; }>; protected generateSubDirectories(options: UploadFileLocalOptionsInterface): string; protected generateUniqueFileName(ext: string, options: UploadFileLocalOptionsInterface): string; protected getFileInfo(file: FileType, options: UploadFileLocalOptionsInterface): Promise<{ file: FileType; fileName: string; fileType: FileTypeResult; }>; protected getReadStream(file: FileType): Promise; protected downloadFile(url: string): Promise; protected createReadStream(safePath: string, options?: GetFileStreamLocalOptionsInterface): fs.ReadStream; protected joinPath(...paths: string[]): string; }