Registry / storage / b2-cloud-storage

b2-cloud-storage

JSON →
library1.1.2jsnpmunverified

b2-cloud-storage v1.1.2 is a Node.js client for Backblaze B2 Cloud Storage API, actively maintained by Nodecraft. It wraps all current B2 API operations, providing helper methods for uploading files of all sizes, including large file chunking and automatic retries. Released under MIT license, it adheres to Backblaze integration guidelines. As of 2025, it requires Node >=20 and npm >=10. Distinguishes itself by handling large file uploads seamlessly, with progress callbacks and error handling built-in, unlike simpler HTTP clients.

npm install b2-cloud-storage
INSTALL
IMPORT
SIG · B2-CLOUD-STORAGE
B
b2-cloud-storage
storagejavascriptv1.1.2
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
const b2CloudStorage = require('b2-cloud-storage');
import b2CloudStorage from 'b2-cloud-storage';
CommonJS only. The package does not export ESM and has no named exports.
b2CloudStorage with new
const b2 = new b2CloudStorage({ auth: { accountId: '...', applicationKey: '...' } });
b2CloudStorage({ auth: ... });
The constructor must be called with new; omitting new leads to undefined.

Shows how to authorize and upload a file with progress tracking using callback style.

const b2CloudStorage = require('b2-cloud-storage'); const b2 = new b2CloudStorage({ auth: { accountId: process.env.B2_ACCOUNT_ID ?? '', applicationKey: process.env.B2_APPLICATION_KEY ?? '' } }); b2.authorize(function(err) { if (err) { console.error('Authorization failed:', err); return; } b2.uploadFile('/path/to/local/file.txt', { bucketId: process.env.B2_BUCKET_ID ?? '', fileName: 'remote/path/file.txt', contentType: 'text/plain', onUploadProgress: function(update) { console.log(`Progress: ${update.percent}% (${update.bytesDispatched}/${update.bytesTotal})`); } }, function(err, results) { if (err) { console.error('Upload failed:', err); return; } console.log('Upload successful:', results); }); });
Debug
Known issues
breakingNode.js >=20 required. Older versions will cause runtime errors.
fix
Upgrade Node.js to v20 or higher.
affects: >=1.0.0
gotchaThe constructor is not callable without new (missing 'new' keyword causes silent failure).
fix
Always use 'new b2CloudStorage(...)'.
affects: >=1.0.0
gotchaCallback style only; no promise or async/await support.
fix
Wrap calls in Promises manually if needed, e.g., new Promise((resolve, reject) => b2.authorize(err => err ? reject(err) : resolve())).
affects: all
Errors
Common errors & fixes
TypeError: b2CloudStorage is not a constructor
Missing 'new' keyword when instantiating.
fix
Use 'new b2CloudStorage(...)'
Error: bucketId is required
Missing bucketId in upload options.
fix
Provide a valid bucketId in the options object.
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
37 hits · last 30 days
node
30
OpenAI (training)
1
Resources
b2-cloud-storage — npm install b2-cloud-storage · libregistry