Auto-Cleanup of Cloudflare R2 Files Older Than 2 Weeks (+ Telegram Notifications)

Go to Workflow
199 views
Built by Mobder Mobder
Created on May 27, 2025

Description

This workflow automatically connects to a Cloudflare R2 bucket (via S3-compatible API), filters out files older than 14 days, deletes them, and then sends a Telegram notification for each deletion. It runs on a daily schedule.

πŸ•˜ Schedule Trigger
Executes the workflow once a day at a specified hour (e.g., 9 AM).

πŸ“¦ S3 Node – List Files
Retrieves all objects from a specific folder (prefix) in a Cloudflare R2 bucket using the S3 API.

πŸ”Ž Code Node – Filter Files Older Than 2 Weeks
Filters the retrieved files by comparing their LastModified timestamps to the current date. Files older than 14 days (2 weeks) are selected for deletion.

πŸ—‘οΈ S3 Node – Delete File
Deletes each filtered file from the R2 bucket.

πŸ“¨ Telegram Node – Notify Deletion
Sends a Telegram message with the name of the deleted file to a specified chat ID. The message includes:

Nodes Used (3)

Code
n8n-nodes-base.code
S3
n8n-nodes-base.s3
Telegram
n8n-nodes-base.telegram