StorageStorage ServicesBackblaze B2

Backblaze B2

Last updated:

Backblaze B2

Overview

Backblaze B2 is an S3-compatible cloud storage service with competitive pricing. It provides reliable, cost-effective storage for applications.

Installation

npm install @aws-sdk/client-s3 @aws-sdk/credential-providers @aws-sdk/s3-request-presigner @aws-sdk/signature-v4-crt aws-crt @aws-sdk/types

Usage

Backblaze B2 is S3-compatible, so use the S3Storage with B2 endpoint:

import { S3Storage } from "@visulima/storage/provider/aws";
import { backblaze } from "@visulima/storage/provider/aws/s3/clients";

const clientConfig = backblaze({
    applicationKeyId: process.env.B2_APP_KEY_ID!,
    applicationKey: process.env.B2_APP_KEY!,
    region: process.env.B2_REGION || "us-west-000",
});

const storage = new S3Storage({
    bucket: "my-bucket",
    ...clientConfig,
});

Configuration

Environment Variables

process.env.B2_APP_KEY_ID = "your-application-key-id";
process.env.B2_APP_KEY = "your-application-key";
process.env.B2_REGION = "us-west-000";

const clientConfig = backblaze(); // Uses environment variables
const storage = new S3Storage({
    bucket: "my-bucket",
    ...clientConfig,
});

With Explicit Parameters

const clientConfig = backblaze({
    applicationKeyId: "your-application-key-id",
    applicationKey: "your-application-key",
    region: "us-west-000",
});

Regions

Backblaze B2 regions:

  • us-west-000 - US West
  • us-west-001 - US West (alternate)
  • us-west-002 - US West (alternate)
  • eu-central-003 - EU Central

Features

  • Cost-Effective: Competitive pricing for storage and egress
  • S3-Compatible: Full S3 API compatibility
  • Reliable: High durability and availability
  • Scalable: Unlimited storage capacity

Best Practices

  1. Choose appropriate region - Select region closest to your users
  2. Monitor costs - Track storage and egress costs
  3. Use lifecycle policies - Automatically manage file lifecycle
  4. Configure CORS - Set up CORS for web applications
  5. Enable versioning - Use B2 versioning for important files
Support

Contribute to our work and keep us going

Community is the heart of open source. The success of our packages wouldn't be possible without the incredible contributions of users, testers, and developers who collaborate with us every day.Want to get involved? Here are some tips on how you can make a meaningful impact on our open source projects.

Ready to help us out?

Be sure to check out the package's contribution guidelines first. They'll walk you through the process on how to properly submit an issue or pull request to our repositories.

Submit a pull request

Found something to improve? Fork the repo, make your changes, and open a PR. We review every contribution and provide feedback to help you get merged.

Good first issues

Simple issues suited for people new to open source development, and often a good place to start working on a package.
View good first issues