fs-gzip-blob-storage v4.0.0
fs-gzip-blob-storage
Blob storage on a filesystem, with gzip, streams and promises API.
This is a wrapper for
fs-blob-storage
Requirements
This module requires ES6 with Node >= 16.
Installation
npm install fs-gzip-blob-storageAdditionally for Typescript:
npm install -D @types/nodeUsage
import FsGzipBlobStorage from "fs-gzip-blob-storage"DEFAULT_EXT
The default ext option is ''
DEFAULT_GZIP_EXT
The default gzipExt option is '.gz'
DEFAULT_PART
The default part option is '.part'
constructor
const storage = new FsGzipBlobStorage(options)Options:
extis a defaultextargument for methods (optional, default:DEFAULT_EXT)partis a defaultpartargument for methods (optional, default:DEFAULT_PART)exclusiveif is true then can't create new object if already exists with the same key (optional, default: false)gzipExtis an extra extension for gzipped files (optional, default:DEFAULT_GZIP_EXT)gzipOptionsis an object with options for gzip/gunzip (optional)pathis a directory path of the storage (optional, default: ".")
Example:
const storage = new FsGzipBlobStorage({
path: "/usr/share/man",
exclusive: true,
})createWriteStream
const writable = await storage.createWriteStream(key, options)Options:
extis a default extension added to the file name for the object (optional, default:this.ext)partis a extension added to the file name which can be later committed (optional, default:this.part)
Creates a writable stream for a new object in the storage. The object is
gzipped and stored with the file name based on key and ext and gzipExt
and part. Throws an error if has occurred and if the file already exists
for exclusive mode.
createReadStream
const readable = await storage.createWriteStream(key, options)Options:
extis a default extension added to the file name for the object (optional, default:this.ext)
Creates a readable stream for an existing, gunzipped object in the storage. Throws an error if has occurred or if the object doesn't exist or its size is zero.
commit
await storage.commit(key, options)Options:
extis a default extension added to the file name for the object (optional, default:this.ext)partis a extension added to the file name which can be later committed (optional, default:this.part)
Commits the object in the storage. It means that the file name for the object is renamed and the additional extension for partial objects is removed. Throws an error if has occurred or the object doesn't exist.
remove
await storage.remove(key, options)Options:
extis a default extension added to the file name for the object (optional, default:this.ext)
Removes the object from the storage. Throws an error if has occurred or the object doesn't exist.
License
Copyright (c) 2018-2024 Piotr Roszatycki piotr.roszatycki@gmail.com