Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
B

backblaze-b2

> 编程语言
Open source

Node.js Library for the Backblaze B2 Storage Service

195 stars0 likes1 views
WebsiteGitHub

About

Node.js Library for the Backblaze B2 Storage Service

Backblaze B2 Node.js Library

A customizable B2 client for Node.js:

  • Uses axios. You can control the axios instance at the request level (see axios and axiosOverride config arguments) and at the global level (see axios config argument at instantiation) so you can use any axios feature.
  • Automatically retries on request failure. You can control retry behaviour using the retries argument at instantiation.

Usage

This library uses promises, so all actions on a B2 instance return a promise in the following pattern:

javascript
b2.instanceFunction(arg1, arg2).then(
    successFn(response) { ... },
    errorFn(err) { ... }
);

Basic Example

javascript
const B2 = require('backblaze-b2');

const b2 = new B2({
  applicationKeyId: 'applicationKeyId', // or accountId: 'accountId'
  applicationKey: 'applicationKey' // or masterApplicationKey
});

async function GetBucket() {
  try {
    await b2.authorize(); // must authorize first (authorization lasts 24 hrs)
    let response = await b2.getBucket({ bucketName: 'my-bucket' });
    console.log(response.data);
  } catch (err) {
    console.log('Error getting bucket:', err);
  }
}

Response Object

Each request returns an object with:

  • status - int, html error Status
  • statusText
  • headers
  • config
  • request
  • data - actual returned data from backblaze, https://www.backblaze.com/b2/docs/calling.html

How it works

Each action (see reference below) takes arguments and constructs an axios request. You can add additional axios options at the request level using:

  • The axios argument (object): each property in this object is added to the axios request object only if it does not conflict with an existing property.
  • The axiosOverride argument (object): each property in this object is added to the axios request object by overriding conflicting properties, if any. Don't use this unless you know what you're doing!
  • Both axios and axiosOverride work by recursively merging properties, so if you pass axios: { headers: { 'your-custom-header': 'header-value' } }, the entire headers object will not be overridden - each header property (your-custom-header) will be compared.

Reference

…

If an upload is interrupted, the fileId can be used to get a list of parts which have already been transmitted. You can then send the remaining parts before finally calling b2.finishLargeFile().

javascript
let response = await b2.listParts({
    fileId,
    startPartNumber: 0,
    maxPartCount: 1000
})

Changes

See the CHANGELOG for a history of updates.

Upgrading from 0.9.x to 1.0.x

For this update, we've switched the back end HTTP request library from request to axios as it has better Promise and progress support built in. However, there are a couple changes that will break your code and ruin your day. Here are the changes:

  • The Promise resolution has a different data structure. Where previously, the request response data was the root object in the promise resolution (res), this data now resides in res.data.
  • In v0.9.12, we added request progress reporting via the third parameter to then(). Because we are no longer using the same promise library, this functionality has been removed. However, progress reporting is still available by passing a callback function into the b2.method() that you're calling. See the documentation below for details.
  • In v0.9.x, b2.downloadFileById() accepted a fileId parameter as a String or Number. As of 1.0.0, the first parameter is now expected to be a plain Object of arguments.

Contributing

Contributions, suggestions, and questions are welcome. Please review the contributing guidelines for details.

Authors and Contributors

  • Yakov Khalinsky (@yakovkhalinsky)
  • Ivan Kalinin (@IvanKalinin) at Isolary
  • Brandon Patton (@crazyscience) at Isolary
  • C. Bess (@cbess)
  • Amit (@Amit-A)
  • Zsombor Paróczi (@realhidden)
  • Oden (@odensc)

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScriptbackblazenodejs

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言