A simple Cloudflare Worker that serves text files from an R2 bucket based on the URL path.
- View text files directly from your R2 bucket
- Simple URL-based access (e.g.,
/path/to/your/file.txt) - Minimal and efficient implementation
-
Install dependencies:
npm install
-
Configure your R2 bucket: Make sure you have created an R2 bucket named
ramus-filesin your Cloudflare account.If you need to use a different bucket name, update the
bucket_nameinwrangler.jsonc. -
Local development:
npm run dev
-
Deploy to Cloudflare:
npm run deploy
Once deployed, access your files using:
https://r2-text-viewer.your-subdomain.workers.dev/path/to/file.txt
The worker will display the text content of the file if it exists, or appropriate error messages if the file isn't found.
- Currently only supports text files
- No authentication or authorization mechanisms
- No caching configuration
MIT