Jump to content

Recommended Posts

Posted

I’ve been working on a module to store ProcessWire files directly on Backblaze B2, and wanted to share it with the community.

Why I Built This

I needed to host video content without breaking the bank on storage costs. AWS S3 was too expensive, and I wanted something that integrates seamlessly with ProcessWire’s existing file fields.

Key Features

  • 🚀 Direct B2 Upload - Files go straight to Backblaze, no local storage needed
  • 💰 Dirt Cheap - $6/TB/month (AWS S3 costs 5x more)
  • 🌐 Custom Domain Support - Use your own CDN domain
  •  Cloudflare Integration - Combine with Cloudflare for FREE bandwidth
  • 📦 Works with Repeaters - Multiple files per repeater item
  • 🎬 Perfect for Video - Tested with Plyr, Video.js, and HTML5 video

Real Cost Savings

Here’s what I’m actually paying for 500GB of video storage:

Backblaze B2 + Cloudflare:
- Storage: $3/month
- Bandwidth: $0 (free via Cloudflare Bandwidth Alliance)
- Total: $3/month

AWS S3 (same usage):
- Storage: $11.50/month
- Bandwidth: $450/month (5TB)
- Total: $461.50/month

That’s a 99% savings on bandwidth costs!

How It Works

The module extends ProcessWire’s file fields to upload directly to Backblaze B2. You can use it just like regular file fields:

// Single video
<video controls>
    <source src="<?= $page->b2_video->url ?>" type="video/mp4">
</video>

// Multiple videos in repeater
<?php foreach($page->videos as $item): ?>
    <?php foreach($item->b2_video as $video): ?>
    <video controls>
        <source src="<?= $video->b2url ?>" type="video/mp4">
    </video>
    <?php endforeach; ?>
<?php endforeach; ?>

Cloudflare CDN Integration

Want free bandwidth? Here’s the magic setup:

  1. CNAME: cdn.yourdomain.com  f005.backblazeb2.com (with Cloudflare proxy)
  2. Transform Rule: Rewrite paths to include /file/bucket-name/
  3. Module setting: Enable custom domain

Now all files serve through Cloudflare’s global CDN with zero bandwidth costs thanks to the Bandwidth Alliance partnership.

Setup is Simple

  1. Create Backblaze B2 bucket
  2. Configure module with API keys
  3. Create field (type: FieldtypeFileB2)
  4. Add field to template
  5. Upload files - they go straight to B2!

Optional: Add Cloudflare for free bandwidth and caching.

Use Cases

  • Video hosting (my use case)
  • Large image galleries
  • Audio files / podcasts
  • Downloadable resources
  • Any high-bandwidth file hosting

Technical Details

  • Works with public and private buckets
  • Supports custom Cache-Control headers
  • Files are deleted from local server after upload
  • Can use custom domains via Cloudflare
  • CORS configurable for cross-domain access

Try It Out

GitHub: https://github.com/mxmsmnv/FieldtypeFileB2

  • Like 10
  • Thanks 3
Posted

Haven't tried the profile or field, but the walks in Switzerland videos are truly awesome) 

Wonder if page variations are being created well on the fly. Is it taken care of?

Posted
10 hours ago, Ivan Gretsky said:

Wonder if page variations are being created well on the fly. Is it taken care of?

What do you mean?

Posted

What I was thinking about is PW image field creates variations of image (scaled down, resized and so on). And it does so not on image load, but during render. @maximus, you surely know about this. And PW puts all those into the same folder for all image fields of the same page. So I was wondering if and how this field handles those cases. I guess it does not as it is file field, not image. Or am I wrong?

Posted

@maximus I have a subdomain with CloudFlare Image Transformations successfully running on it. Congrats on this wonderful module. Can't wait to try it out. 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...