https://github.com/sudo-self/bucket-buddy
Access an R2 bucket with a Cloudflare Worker
https://github.com/sudo-self/bucket-buddy
Last synced: 4 months ago
JSON representation
Access an R2 bucket with a Cloudflare Worker
- Host: GitHub
- URL: https://github.com/sudo-self/bucket-buddy
- Owner: sudo-self
- Created: 2024-09-12T03:45:28.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-22T20:54:57.000Z (over 1 year ago)
- Last Synced: 2025-06-06T10:02:09.233Z (about 1 year ago)
- Language: HTML
- Size: 731 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bucket Buddy 🪣

## Overview
Bucket Buddy is a tool that allows users to interact with Cloudflare R2 storage using a simple interface. It includes a server-side worker for handling file uploads, downloads, and management.
### Components
1. **index.js** - [Worker]
2. **index.html** - [R2 Bucket]
## Getting Started
To create your Cloudflare Worker, run the following command:
```bash
npm create cloudflare@latest -- your-worker-name
```
CRUD Operations
PUT: Uploads an object to the bucket.
GET: Retrieves an object from the bucket.
DELETE: Removes an object from the bucket.
LIST: Retrieves a list of objects in the bucket.
[[r2_buckets]]
binding = 'MY_BUCKET'
bucket_name = 'your-bucket-name-here'
Then place a secret in your worker
wrangler secret put MY_BUCKET
YOUR-R2-STORAGE-API-KEY
1. binding in wrangler.toml
2. secret
3. Replace src/index.js with the one from this repo ```index.js```
4. deploy your worker
npm wrangler deploy
open ```bucket_buddy.py``` and append this line with your worker URL
self.api_url = 'https://your-worker.workers.dev'
***make sure your bucket is configured for public access***
### runpython bucket_buddy.py

alternatively upload the index.html to you bucket then access the buddy at https://your-worker.workers.dev/index.html
## coors cross-origin
```[
{
"AllowedOrigins": [
"http://YOUR-BUCKET-NAME",
"https://YOUR-WORKER-NAME"
],
"AllowedMethods": [
"GET",
"PUT",
"POST",
"DELETE"
],
"AllowedHeaders": [
"*"
],
"ExposeHeaders": [
"Content-Length",
"Content-Type"
],
"MaxAgeSeconds": 3600
}
]
```