npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tweedegolf/sab-adapter-backblaze-s3

v3.0.1

Published

Provides an abstraction layer for interacting with Amazon S3 and S3 compatible cloud services.

Readme

Backblaze S3 Adapter

An adapter that provides an abstraction layer over the Backblaze B2 S3 API. It extends AdapterAmazonS3 and overrides some methods because the implementation of Backblaze is not fully compatible.

This adapter is one of the adapters that is meant to be used as a plugin of the Storage Abstraction package. However it can be used standalone as well, see below.

The API of the adapter abstracts away the differences between the API's of cloud storage services. The API only supports the basic, most commonly used cloud service operations such as creating a bucket, storing files and so on.

It is also possible to access all the specific functionality of the cloud service API through the service client of the adapter, see here.

If you are new to the Storage Abstraction library you may want to read this first.

Backblaze B2 also has a native API. You can use this adapter if you want to use the native API.

import { Storage, StorageType } from "@tweedegolf/storage-abstraction";

const configuration = {
  type: StorageType.BACKBLAZE_S3,
};

const storage = new Storage(configuration);

const result = await storage.listBuckets();

console.log(result);

The Storage class is cloud service agnostic and doesn't know anything about the adapter it uses and adapters are completely interchangeable. It only expects the adapter to have implemented all methods of the IAdapter interface, see the API.

When you create a Storage instance it checks the mandatory provider key in the configuration object and then loads the appropriate adapter module automatically from your node_modules folder using require(). For more information please read this.

Configuration

The configuration object that you pass to the Storage constructor is forwarded to the constructor of the adapter.

The Storage constructor is only interested in the provider key of the configuration object, all other keys are necessary for configuring the adapter.

The Storage constructor expects the configuration to be of type StorageAdapterConfig.

The adapter expects the configuration to be of type AdapterConfig or a type that extends this type.

export interface AdapterConfig {
  bucketName?: string;
  [id: string]: any; // any mandatory or optional key
}

export interface StorageAdapterConfig extends AdapterConfig {
  type: string;
}

The type of the configuration object for this adapter:

export interface AdapterConfigS3 extends AdapterConfig {
  region?: string; //
  endpoint: string; // mandatory
  credentials?: {
    accessKeyId: string;
    secretAccessKey: string;
  };
  accessKeyId: string;
  secretAccessKey: string;
}

Note that region is mandatory for the AWS SDK S3Client but it will also be picked up as environment variable AWS_REGION; therefor it is not mandatory in the config object.

Also note that accessKeyId, secretAccessKey and endpoint are mandatory!

Examples

Examples with configuration object:

const s = new Storage({
  type: StorageType.BACKBLAZE_B2,
  accessKeyId: 'your-key-id'
  secretAccessKey: 'your-secret'
  endpoint: "https://s3.eu-central-003.backblazeb2.com",
  region: "eu-central-003",
});

const s = new Storage({
  type: StorageType.BACKBLAZE_B2,
  accessKeyId: 'your-key-id'
  secretAccessKey: 'your-secret'
  endpoint: "https://s3.eu-central-003.backblazeb2.com",
  region: "eu-central-003",
  bucketName: "the-buck",
});

Same example with configuration url:

// Cubbit S3 compatible
const s = new Storage(
  "s3://your-key-id:your-access-key?endpoint=https://s3.eu-central-003.backblazeb2.com&region=eu-central-003"
);

const s = new Storage(
  "s3://your-key-id:your-access-key@the-buck?endpoint=https://s3.eu-central-003.backblazeb2.com&region=eu-central-003"
);

The endpoint is https://s3.<REGION>.backblazeb2.com. Although the region is part of the endpoint AWS SDK still expects you to set a value for region in the configuration or in the AWS_REGION environment variable. You can simply retrieve your region from the endpoint.

For more information about configuration urls please read this.

Standalone

You can also use the adapter standalone, without the need to create a Storage instance:

import { AdapterAmazonS3 } from "@tweedegolf/sab-adapter-amazon-s3";

const a = new AdapterAmazonS3();
const r = await a.listBuckets();
console.log(r);

API

For a complete description of the Adapter API see this part documentation of the Storage Abstraction package readme.

Exceptions

The S3 implementation of Backblaze B2 does not support creating a public bucket. You can only make a bucket public using the Backblaze web console.

const s = new Storage(config);
const {value, error} = s.createBucket("myBucket", {public: true});
console.log(value)
// prints: 
// `Bucket 'myBucket' created successfully but you can only make this bucket public using the Backblaze B2 web console`