Registry / storage / fs-blob-storage

fs-blob-storage

JSON →
library4.1.0jsnpmunverified

A Node.js library for blob storage on filesystems with streams and promises API. Current stable version is 4.1.0, released under ISC license and requiring Node >= 16. It provides atomic operations, partial file support, and optional exclusive locking. Compared to similar packages like 'fs-blob-store', this library offers simpler API and built-in commit/partial file handling.

npm install fs-blob-storage
INSTALL
IMPORT
SIG · FS-BLOB-STORAGE
F
fs-blob-storage
storagejavascriptv4.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FsBlobStorage
import FsBlobStorage from 'fs-blob-storage'
const FsBlobStorage = require('fs-blob-storage')
Default export; ESM-only since v4
DEFAULT_EXT
import { DEFAULT_EXT } from 'fs-blob-storage'
import DEFAULT_EXT from 'fs-blob-storage'
Named export, not default
FsBlobStorage (TypeScript)
import FsBlobStorage from 'fs-blob-storage'
import { FsBlobStorage } from 'fs-blob-storage'
Default export, not named; types are included in the package

Shows creating a storage instance, writing a blob using streams, committing it, and reading it back.

import FsBlobStorage from 'fs-blob-storage'; const storage = new FsBlobStorage({ path: './blobs', }); async function example() { // Write a blob const writable = await storage.createWriteStream('myfile'); writable.end('Hello World'); // The file is stored as myfile.part until committed await storage.commit('myfile'); // Now it's myfile // Read a blob const readable = await storage.createReadStream('myfile'); readable.on('data', (chunk) => { console.log(chunk.toString()); }); } example().catch(console.error);
Debug
Known issues
breakingThe package uses ESM only since v4.0.0. Requiring via CommonJS will fail.
fix
Use import syntax or upgrade to Node 16+ and set { "type": "module" } in package.json.
affects: >=4.0.0
gotchacreateReadStream throws an error if the object does not exist or its size is zero.
fix
Use try/catch or check existence before reading with stat.
affects: *
gotchaPartial files with .part extension are used; you must call commit() to rename the file to remove the extension.
fix
After writing via createWriteStream, always call storage.commit(key) to finalize the blob.
affects: *
gotchaThe library is not compatible with NTFS filesystems due to rename behavior.
fix
Use on POSIX-like filesystems (Linux, macOS).
affects: *
deprecatedThe 'exclusive' option in constructor can cause race conditions if not used carefully.
fix
Use with caution; consider file locking alternatives.
affects: *
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
CommonJS environment trying to use ESM import.
fix
Set { "type": "module" } in package.json or use dynamic import().
Error: ENOENT: no such file or directory, open '...'
The blob or directory does not exist.
fix
Ensure the storage directory exists and the key is correct.
Error: Object already exists (exclusive mode)
Trying to create a blob with exclusive: true and the key already exists.
fix
Remove the existing blob first or disable exclusive mode.
TypeError: storage.createWriteStream is not a function
Using default export incorrectly, e.g., import { FsBlobStorage } instead of import FsBlobStorage.
fix
Use default import: import FsBlobStorage from 'fs-blob-storage'.
Upgrade
Version history
4.1.0latest on npm
Audit
Dependencies
@types/nodeoptionalRequired for TypeScript type definitions when using the package with TypeScript
Agent activity
21 hits · last 30 days
node
20
Amazon
1
Resources
fs-blob-storage — npm install fs-blob-storage · libregistry