Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 1.55 KB

README.md

File metadata and controls

26 lines (20 loc) · 1.55 KB

R2 TTL WORKER

Use this template to create a Cloudflare Worker that will allow you to automatically delete objects older than 30 days in a R2 Bucket.

Getting started

  1. Install wrangler using npm npm i -g wrangler@latest.
  2. Login with your Cloudflare account using wrangler login
  3. Create an .env file following the guide in the Cloudflare Workers documentation (env file will not be commited).
  4. Get the name of the bucket you want to use with the wrangler r2 bucket list command.
  5. Edit your wrangler.toml file and change YOUR BUCKET NAME with the name of the bucket you want to bind.
  6. Run wrangler publish and the worker will be created.

Changing the Worker name

You can change the name of the Worker simply by changing the name= variable in your wrangler.toml file

Changing cron scheduled time

Just go to wrangler.toml and replace crons = [ "0 8 * * *" ] with your needed crons (crons tutorial)