Cloudflare Worker to make a R2 Bucket public!

Overview

r2-public-worker

A Cloudflare Worker to make your R2 bucket public!

Minimum Requirements

  1. Cloudflare Account
  2. wrangler >= 2.0.2

Note: Ensure you are using at the minimum specified version of wrangler.

Setup

  1. Fork this repo

  2. Install dependencies (including Wrangler 2)

npm install
  1. Create a bucket to be made public
wrangler r2 bucket create public
  1. Update the wrangler.toml to bind the R2 bucket
[[r2_buckets]]
binding = 'PUBLIC' # <~ valid JavaScript variable name
bucket_name = 'public'
  1. Deploy the worker!
wrangler publish
  1. πŸŽ‰ You've got a public bucket

Give it a try: https://r2-public-worker.cdmacken.workers.dev/duck.png

URL's even support spaces! https://r2-public-worker.cdmacken.workers.dev/space%20duck.webp

You might also like...

Airtable + Cloudflare Workers URL Shortener 🌀

Airtable + Cloudflare Workers URL Shortener 🌀

tableflare Airtable + Cloudflare Workers URL Shortener 🌀 Quick Start Airtable Generate your Airtable API key from your account dashboard: https://air

Oct 16, 2022

Build your Cloudflare Workers with esbuild.

build-worker Bundle your Cloudflare Worker with esbuild instead of webpack. (It's ridiculously faster!) Wrangler v1 uses webpack. Wrangler v2 is using

Oct 24, 2022

Store and Deliver images with R2 backend Cloudflare Workers.

Store and Deliver images with R2 backend Cloudflare Workers.

r2-image-worker Store and Deliver images with Cloudflare R2 backend Cloudflare Workers. Synopsis Deploy r2-image-worker to Cloudflare Make a base64 st

Jan 3, 2023

generate statistics on the number of audience minutes your site is generating, and if readers make it to the end of your screeds

generate statistics on the number of audience minutes your site is generating, and if readers make it to the end of your screeds

audience-minutes generate statistics on the number of audience minutes your site is receiving, and if readers make it to the end of your screeds. β€œIf

Dec 28, 2022

A cloudflare worker based REST API for your R2 bucket.

A cloudflare worker based REST API for your R2 bucket. Usage: Change the bucket_name and preview_bucket_name in wrangler.toml if you want. Set ENCRYPT

Nov 7, 2022

Cloudflare Worker that will allow you to progressively migrate files from an S3-compatible object store to Cloudflare R2.

A Cloudflare Worker for Progressive S3 to R2 Blog Post: https://kian.org.uk/progressive-s3-to-cloudflare-r2-migration-using-workers/ This is a Cloudfl

Dec 30, 2022

Connect to a Postgres database from a Cloudflare Worker, using Cloudflare Tunnel

Cloudflare Workers Postgres Client This is an experimental module. Heavily based on cloudflare/worker-template-postgres, but cleaned up and bundled in

Dec 22, 2022

A template for WebSockets powered Cloudflare Worker project using graphql-ws

🚑 graphql-ws on Cloudflare Workers A template for WebSockets powered Cloudflare Worker project using graphql-ws. The worker serves the following rout

Dec 18, 2022

A Cloudflare Worker for fetching data from Twitter User API.

cloudflare-worker-twitter This is a Cloudflare Worker for fetching data from Twitter User API. ❔ About this project I created this Worker to hide my A

Oct 1, 2022

Easily redirect one entire domain to another with a serverless Cloudflare Worker.

Easily redirect one entire domain to another with a serverless Cloudflare Worker.

Domain Redirecting with Cloudflare Workers Easily redirect one entire domain to another with a serverless Cloudflare Worker. All paths and other data

Dec 11, 2022

A Cloudflare Worker that translates TeX to SVG

A Cloudflare Worker that translates TeX to SVG

TeX SVG Worker A Cloudflare Worker that translates TeX to SVG.

Jan 9, 2023

A cloudflare worker to use the user-agent for ~~rickrolling~~ without a discord embed

nextcord.gay A cloudflare worker to use the user-agent for rickrolling without a discord embed Build npm run build Find the output in ./dist/worker.mj

Oct 4, 2022

Cloudflare worker function to update github bio automatically with leetcode and codeforces profile stats πŸš€

Stats check πŸ”’ Cloudflare worker function to update github bio automatically with leetcode and codeforces profile stats πŸš€ You can see it in action he

Feb 15, 2022

Send emails using Cloudflare Worker, for free.

Email API for Proselog. Not intended for use outside of Proselog, but it should work with any worker, without any configuration. import { sendEmail }

Nov 7, 2022

An example Worker for copying Cloudflare Pub/Sub messages to R2 storage

pubsub-to-r2 An example Cloudflare Worker that acts as an on-publish hook for Pub/Sub and copies a subset of messages to R2 object storage. To deploy

Jul 1, 2022

Using Cloudflare worker to generate host list from firebog to keep updated.

AdGuardCloudflareHostGenerator Use a cloudflare worker to generate a up to date list from FireBog's ticked list found at https://v.firebog.net/hosts/l

Nov 30, 2022

A CloudFlare Worker / script / bot to sync Notion pages publicly as GitHub Discussions.

A CloudFlare Worker / script / bot to sync Notion pages publicly as GitHub Discussions.

notion-github-sync This bot syncs public Notion pages as GitHub Discussions/Issues. It's done periodically, based on the pages shared with the Notion

Dec 22, 2022

NodeJS application to upload an image to a S3 Bucket on AWS.

NodeJS application to upload an image to a S3 Bucket on AWS.

node-upload-image-to-s3-bucket NodeJS application to upload an image to a S3 Bucket on AWS. How it works: You must make a POST request to /upload-imag

Sep 28, 2022

A GitHub Action to cache your workload to a Google Cloud Storage bucket.

A GitHub Action to cache your workload to a Google Cloud Storage bucket.

Google Cloud Storage Cache Action GitHub already provides an awesome action to cache your workload to Azure's servers hosted in United States. However

Dec 15, 2022
Comments
  • How can I add cache to the public worker?

    How can I add cache to the public worker?

    Hi, thank you very much for creating this, it's a great help! Right now I've just started all this R2 stuff, there is hardly any guide beyond the docs. Do you know how I could include cache to your repository? I've been doing some research in the docs and some projects (https://community.cloudflare.com/t/how-to-cache-workers-responses-with-r2-backend/386408), but honestly I don't know exactly how to do it, I hope you can help me πŸ™‚

    opened by iamdarkle 3
  • TypeError when navigating to URL

    TypeError when navigating to URL

     "outcome": "exception",
      "scriptName": "r2-public-worker",
      "exceptions": [
        {
          "name": "TypeError",
          "message": "Cannot read properties of undefined (reading 'get')",
          "timestamp": 1655249268624
        }
    

    Uploaded a test file (CSS), Navigated to my worker URL, Presented with an error,

    opened by GarlandM 1
Owner
Cole Mackenzie
Software developer building backend services and data pipelines. TZ=America/Los_Angeles
Cole Mackenzie
Easily redirect one entire domain to another with a serverless Cloudflare Worker.

Domain Redirecting with Cloudflare Workers Easily redirect one entire domain to another with a serverless Cloudflare Worker. All paths and other data

Erisa A 19 Dec 11, 2022
Send emails using Cloudflare Worker, for free.

Email API for Proselog. Not intended for use outside of Proselog, but it should work with any worker, without any configuration. import { sendEmail }

Proselog 65 Nov 7, 2022
Using Cloudflare worker to generate host list from firebog to keep updated.

AdGuardCloudflareHostGenerator Use a cloudflare worker to generate a up to date list from FireBog's ticked list found at https://v.firebog.net/hosts/l

Jake Steele 14 Nov 30, 2022
Use Cloudflare Workers Cron Triggers to keep your Hetzner Cloud Firewall allowing the latest list of Cloudflare IPs, or any other lists!

Hetzner Cloud Firewall automation with Cloudflare Workers Heavily inspired by xopez/Hetzner-Cloud-Firewall-API-examples, this repository holds a Cloud

Erisa A 9 Dec 17, 2022
A tiny utility to asynchronously drive a namespace exposed through a Worker.

proxied-worker Social Media Photo by Ricardo Gomez Angel on Unsplash A tiny utility to asynchronously drive a namespace exposed through a Shared/Servi

Andrea Giammarchi 43 Dec 8, 2022
Redirect requests of current origin to another domain with Service Worker.

Service Worker to Redirect Origin This is a tool for your static website which could intercept all GET requests of the origin domain and redirect them

Menci 9 Aug 28, 2022
A tool library for handling window && iframe && worker communication based on the JSON RPC specification

rpc-shooter A tool library for handling window && iframe && worker communication based on the JSON RPC specification δΈ€δΈͺ基于 JSON-RPC θ§„θŒƒη”¨δΊŽε€„η† window && if

θ‡ΌηŠ€ 89 Dec 20, 2022
βš™οΈ Offline-capable Astro apps via SWSR (Service Worker Side Rendering)

Astro-service-worker βš™οΈ Offline-capable Astro apps via SWSR (Service Worker Side Rendering) astro-service-worker will take your Astro SSR project, and

Pascal Schilp 41 Dec 4, 2022
Type-safe and Promisified API for Web Worker and Iframe

?? You can help the author become a full-time open-source maintainer by sponsoring him on GitHub. typed-worker Install npm i typed-worker Usage Create

EGOIST 189 Dec 31, 2022
slash-create with Cloudflare Workers template

/create with Cloudflare Workers A slash-create template, using Cloudflare Workers. Getting Started Cloning the repo You can either use degit to locall

Snazzah 13 Jan 3, 2023