cf-b2cdn icon indicating copy to clipboard operation
cf-b2cdn copied to clipboard

Serve private/public B2 bucket files and optionally list directories using Cloudflare's CDN

B2 CDN

Screenshot of a Directory Listing Page

A Cloudflare Worker for serving and browsing content in a private Backblaze B2 bucket.

  • Serve the content in your B2 bucket for free
  • Browse the content in your B2 bucket

Why?

  • Backblaze B2 is cheap file storage
  • Downloading from Backblaze B2 is normally $0.01 per GB
  • Downloading from Backblaze B2 through Cloudflare's CDN is free
  • Private buckets prevent people from downloading from your bucket directly

Setup

Install Wrangler

See Cloudflare's documentation for more information.

wrangler.toml

Copy wrangler.toml.example to wrangler.toml and fill in your own information into the variables. Refer to Cloudflare's documentation for more information.

Secrets

Secrets are like vars but... secret. This Worker only needs one secret named B2SECRET which should contain the applicationKey (the secret part) of your Backblaze B2 application key.

Protected File Listings

You can use Cloudflare Access to require a login for certain subdomains. Let's say you want to publicly share the files in your B2 Bucket, but not allow others to list the files in it, you can set up a separate DIR_DOMAIN and place Cloudflare Access in front of it. There's a lot of supported identity providers. You can make it so only a certain IP can access the directory listing, or only particular Google Accounts.

To Do

  • Implement pagination for enormous folders
  • Implement more efficient calls to b2_list_file_names

License

MIT