@slynova/flydrive
Version:
Flexible and Fluent way to manage storage in Node.js.
107 lines • 3.32 kB
TypeScript
/**
* @slynova/flydrive
*
* @license MIT
* @copyright Slynova - Romain Lanz <romain.lanz@slynova.ch>
*/
/// <reference types="node" />
import { Response, SignedUrlResponse, ContentResponse, ExistsResponse, SignedUrlOptions, StatResponse, FileListResponse, DeleteResponse } from './types';
export default abstract class Storage {
/**
* Appends content to a file.
*
* Supported drivers: "local"
*/
append(location: string, content: Buffer | string): Promise<Response>;
/**
* Copy a file to a location.
*
* Supported drivers: "local", "s3", "gcs"
*/
copy(src: string, dest: string): Promise<Response>;
/**
* Delete existing file.
* The value returned by this method will have a `wasDeleted` property that
* can be either a boolean (`true` if a file was deleted, `false` if there was
* no file to delete) or `null` (if no information about the file is available).
*
* Supported drivers: "local", "s3", "gcs"
*/
delete(location: string): Promise<DeleteResponse>;
/**
* Returns the driver.
*
* Supported drivers: "local", "s3", "gcs"
*/
driver(): unknown;
/**
* Determines if a file or folder already exists.
*
* Supported drivers: "local", "s3", "gcs"
*/
exists(location: string): Promise<ExistsResponse>;
/**
* Returns the file contents as a string.
*
* Supported drivers: "local", "s3", "gcs"
*/
get(location: string, encoding?: string): Promise<ContentResponse<string>>;
/**
* Returns the file contents as a Buffer.
*
* Supported drivers: "local", "s3", "gcs"
*/
getBuffer(location: string): Promise<ContentResponse<Buffer>>;
/**
* Returns signed url for an existing file.
*
* Supported drivers: "s3", "gcs"
*/
getSignedUrl(location: string, options?: SignedUrlOptions): Promise<SignedUrlResponse>;
/**
* Returns file's size and modification date.
*
* Supported drivers: "local", "s3", "gcs"
*/
getStat(location: string): Promise<StatResponse>;
/**
* Returns the stream for the given file.
*
* Supported drivers: "local", "s3", "gcs"
*/
getStream(location: string): NodeJS.ReadableStream;
/**
* Returns url for a given key. Note this method doesn't
* validates the existence of file or it's visibility
* status.
*
* Supported drivers: "s3", "gcs"
*/
getUrl(location: string): string;
/**
* Move file to a new location.
*
* Supported drivers: "local", "s3", "gcs"
*/
move(src: string, dest: string): Promise<Response>;
/**
* Creates a new file.
* This method will create missing directories on the fly.
*
* Supported drivers: "local", "s3", "gcs"
*/
put(location: string, content: Buffer | NodeJS.ReadableStream | string): Promise<Response>;
/**
* Prepends content to a file.
*
* Supported drivers: "local"
*/
prepend(location: string, content: Buffer | string): Promise<Response>;
/**
* List files with a given prefix.
*
* Supported drivers: "local", "s3", "gcs"
*/
flatList(prefix?: string): AsyncIterable<FileListResponse>;
}
//# sourceMappingURL=Storage.d.ts.map