@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.
92 lines (91 loc) • 2.54 kB
TypeScript
import * as plugins from './plugins.js';
import * as interfaces from './interfaces.js';
import { Directory } from './classes.directory.js';
import { MetaData } from './classes.metadata.js';
/**
* 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;
/**
* get the full path to the file
* @returns the full path to the file
*/
getBasePath(): string;
constructor(optionsArg: {
directoryRefArg: Directory;
fileName: string;
});
getContentsAsString(): Promise<string>;
getContents(): Promise<Buffer>;
getReadStream(typeArg: 'webstream'): Promise<ReadableStream>;
getReadStream(typeArg: 'nodestream'): Promise<plugins.stream.Readable>;
/**
* deletes this file
*/
delete(optionsArg?: {
mode: 'trash' | 'permanent';
}): Promise<void>;
/**
* restores
*/
restore(optionsArg?: {
useOriginalPath?: boolean;
toPath?: string;
overwrite?: boolean;
}): 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 | ReadableStream;
encoding?: 'utf8' | 'binary';
}): Promise<void>;
/**
* moves the file to another directory
*/
move(pathDescriptorArg: interfaces.IPathDecriptor): Promise<void>;
hasMetaData(): Promise<boolean>;
/**
* allows updating the metadata of a file
* @param updatedMetadata
*/
getMetaData(): Promise<MetaData>;
/**
* gets the contents as json
*/
getJsonData(): Promise<any>;
writeJsonData(dataArg: any): Promise<void>;
getMagicBytes(optionsArg: {
length: number;
}): Promise<Buffer>;
}