Cloudflare R2 and ShareX Custom Uploader

I've been using ShareX for many years now to quickly share images and small files with friends and coworkers online. It's a fantastic tool, and while you can use it to upload to shared image hosts like Imgur, I have advocated for years to pair it with some cloud storage such as Backblaze B2, so you can continue to own and control your files, and don't have to worry about image compression or any data loss.

One of my most popular blog posts from 2019 details how to use Backblaze B2 with Cloudflare Workers for free image hosting, and uses ShareX as the example uploader for this. I've received so many nice messages over the years from users who have used that post as an introduction to both Backblaze and Cloudflare, and it continues to be a point of discussion online. šŸ‘€

Using Backblaze B2 and Cloudflare Workers for free image hosting
Learn how to setup your own, free image hosting using Backblaze B2 and Cloudflare Workers.

Cloudflare R2

Cloudflare R2 is a new object product from Cloudflare, designed to rival competing products such as Amazon's Simple Storage Service (S3). The best part about Cloudflare R2 is their commitment to the Bandwidth Alliance, and building upon this to provide absolutely zero-cost egress for stored objects!

While that sounds great, we already had free egress with Backblaze R2 and our Cloudflare setup before, so what other things can R2 provide?

  • First-party Workers integration
  • Automatic replication of objects to locations they're frequently requested from
  • Other integrations with Cloudflare products in future

While automatic replication of objects is super cool, I don't really care about that for my personal image hosting, so the most exciting one there for me is the first-party Workers integration, which can simplify my previous setup tremendously. Storage, configuration, DNS, etc. all in once place. šŸŽ‰

Setup

First, you will want to download and install wrangler, Cloudflare's tooling for Workers, and then authenticate using wrangler login. You can find information about this on their docs here.

Next, let's move on to configuring and setting up our R2 bucket.

  1. Run wrangler r2 bucket create <bucket name>. For the purpose of this example, I'll be using sharex-uploads.
  2. You can double check your bucket has been created by running wrangler r2 bucket list.
  3. Clone the GitHub Repository at https://github.com/Cherry/ShareX-R2-Cloudflare-Workers and follow the installation instructions.
  4. All of the necessary configuration should be documented in the README, but if you want to dig into the code, the R2 docs are a great place to start.
GitHub - Cherry/ShareX-R2-Cloudflare-Workers: Custom ShareX Uploader to Cloudflare R2 via Workers
Custom ShareX Uploader to Cloudflare R2 via Workers - GitHub - Cherry/ShareX-R2-Cloudflare-Workers: Custom ShareX Uploader to Cloudflare R2 via Workers
You've successfully subscribed to James Ross
Great! Next, complete checkout for full access to James Ross
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.