@rytass/storages-adapter-local
TypeScript icon, indicating that this package has built-in type declarations

0.2.4 • Public • Published

Rytass Utils - File Storages (Local)

About

File storage utility, covering basic I/O and metadata guessing, and with plugged-in extension, file buffer could be transformed accordingly.

Features

  • [x] Read File
  • [x] Write File
  • [x] Delete File

Storages APIs


constructor(options)

Description

--

Arguments

Parameter Type Required Description
directory string true directory will be used
autoMkdir boolean false should create folder if directory is not exists
converters FileConverter[] false inject extensions for file conversion and respective manipulation

Snippet

import { LocalStorage } from "@rytass/storages-adapter-local";
import { resolve } from 'path';

const storage = new StorageLocalService({
  directory: resolve(__dirname, 'storage'),
});

StorageLocalService.read(key: string, options: ReadBufferFileOptions | ReadStreamFileOptions):Promise<Readable> | Promise<Buffer>

Description

read file from disk

Arguments

Parameter Type Required Description
key string true file name for read
options.format string false buffer/stream

Snippet

const fileStream = await storage.read('targetFile.png');
const fileBuffer = await storage.read('targetFile.png', { options: 'buffer' });

StorageLocalService.remove(key: string):Promise<void>

Description

remove file

Arguments

--

await storage.remove('willRemove.png');

StorageLocalFile.write(file: InputFile): Promise<StorageFile>

Description

write file to disk

Arguments

Parameter Type Required Description
file InputFile true Buffer of Readable stream

Readme

Keywords

Package Sidebar

Install

npm i @rytass/storages-adapter-local

Weekly Downloads

21

Version

0.2.4

License

MIT

Unpacked Size

16.4 kB

Total Files

10

Last publish

Collaborators

  • fantasywind