Adapter

Backblaze B2

Overview

Backblaze B2 is S3-compatible. This adapter is a thin wrapper over @storagesdk/adapters/s3 with Backblaze defaults baked in — the endpoint is built from your region, and the rest of the surface is identical to the S3 adapter.

Configuration

import { Storage } from '@storagesdk/core';
import { backblaze } from '@storagesdk/adapters/backblaze';

const storage = new Storage({
  adapter: backblaze({
    bucket: 'photos',
    region: 'us-west-004',
    accessKeyId: process.env.B2_KEY_ID!,
    secretAccessKey: process.env.B2_APPLICATION_KEY!,
  }),
});
backblaze({
  bucket: string;            // bucket the adapter operates on (must already exist)
  region: string;            // e.g. 'us-west-004', 'eu-central-003'
  accessKeyId: string;       // Backblaze Application Key ID
  secretAccessKey: string;   // Backblaze Application Key
  endpoint?: string;         // override; defaults to `https://s3.<region>.backblazeb2.com`
});

Create an Application Key in the Backblaze console → Application KeysAdd a New Application Key. Scope it to the bucket(s) you intend to use; the Application Key value is shown only once at creation.

Notes