Registry / storage / postgres-blob-store

postgres-blob-store

JSON →
library3.0.0jsnpmunverified

PostgreSQL implementation of abstract-blob-store, currently at version 3.0.0. This package stores binary files as base64 strings in text columns, not as bytea. It is experimental and designed for server-side Node.js use with PostgreSQL. Works with any abstract-blob-store compatible consumer. Last updated in 2016, no recent releases.

npm install postgres-blob-store
INSTALL
IMPORT
SIG · POSTGRES-BLOB-STOR
P
postgres-blob-store
storagejavascriptv3.0.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.

default
✓ import blob from 'postgres-blob-store'
✗ const { blob } = require('postgres-blob-store')
The module exports a single function as default. CommonJS require returns the function directly, not an object.
postgres-blob-store (require)
✓ const blob = require('postgres-blob-store')
✗ const { createBlobStore } = require('postgres-blob-store')
CommonJS require returns the exporter function directly; there is no named export.
TypeScript usage
✓ import blob from 'postgres-blob-store'
This package does not ship TypeScript definitions. You may need to create a .d.ts file or use @types/abstract-blob-store.

Connects to PostgreSQL, reads a file, writes it as a blob, then reads it back to another file.

const blob = require('postgres-blob-store'); const fs = require('fs'); const store = blob({ url: process.env.DATABASE_URL ?? 'postgresql://localhost:5432/blob' }); // Write a blob const ws = store.createWriteStream((err, meta) => { if (err) throw err; console.log('Saved:', meta.key); // Read it back const rs = store.createReadStream(meta.key); rs.pipe(fs.createWriteStream('./output.txt')); }); fs.createReadStream('./input.txt').pipe(ws);
Debug
Known issues
gotchaData stored as base64 text, not bytea, causing ~33% storage overhead
fix
Switch to a blob store that uses bytea, or accept overhead.
affects: >=0.0.0
gotchaExperimental: no official releases since 2016; may have unaddressed bugs
fix
Consider alternatives like node-pg-blob-store or implement using bytea directly.
affects: *
gotchaRequires callback-based initialization; no promise or async/await support
fix
Wrap in a Promise manually for modern Node.js patterns.
affects: *
deprecatedDependency 'through2' is no longer maintained
fix
Replace with native Node.js streams (Transform) in your code.
affects: >=3.0.0
Errors
Common errors & fixes
Error: no pg config
Missing or incorrect connection URL
fix
Ensure you pass {url: 'postgresql://...'} or set DATABASE_URL env var.
TypeError: store.createWriteStream is not a function
Using a named import instead of default import
fix
Use const blob = require('postgres-blob-store'); then blob({...}).createWriteStream(...)
Error: relation "blobs" does not exist
Table not automatically created; need to create it
fix
Run: CREATE TABLE blobs (key text primary key, blob text NOT NULL);
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
abstract-blob-storerequiredRequired interface for blob store compatibility
pgrequiredPostgreSQL client for database operations
through2requiredStream transformation for reading/writing blobs
Agent activity
15 hits · last 30 days
node
14
Amazon
1
Resources
postgres-blob-store — npm install postgres-blob-store · libregistry