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.

74 lines (73 loc) 1.97 kB
/// <reference types="node" resolution-mode="require"/> /// <reference types="node" resolution-mode="require"/> import * as plugins from './smartbucket.plugins.js'; import { Directory } from './smartbucket.classes.directory.js'; export interface IFileMetaData { name: string; fileType: string; size: string; } /** * represents a file in a directory */ export declare class File { /** * creates a file in draft mode * you need to call .save() to store it in s3 * @param optionsArg */ static create(optionsArg: { directory: Directory; name: string; contents: Buffer | string | plugins.stream.Readable; /** * if contents are of type string, you can specify the encoding here */ encoding?: 'utf8' | 'binary'; }): Promise<File>; parentDirectoryRef: Directory; name: string; path: string; metaData: IFileMetaData; constructor(optionsArg: { directoryRefArg: Directory; fileName: string; }); getContentAsString(): Promise<string>; getContentAsBuffer(): Promise<Buffer>; readStreaming(): Promise<void>; /** * removes this file */ remove(): Promise<void>; /** * deletes the file */ delete(): Promise<void>; /** * allows locking the file * @param optionsArg */ lock(optionsArg?: { timeoutMillis?: number; }): Promise<void>; /** * actively unlocks a file * */ unlock(optionsArg?: { /** * unlock the file even if not locked from this instance */ force?: boolean; }): Promise<void>; updateWithContents(optionsArg: { contents: Buffer | string | plugins.stream.Readable; encoding?: 'utf8' | 'binary'; }): Promise<void>; /** * allows updating the metadata of a file * @param updatedMetadata */ updateMetaData(updatedMetadata: any): Promise<void>; }