Vercel Blob can now delete files automatically with a TTL
Pass ttlDays when writing a blob and Vercel deletes it that many days later. No cron job or manual cleanup script required.
Vercel Blob now supports a time-to-live on uploads. Pass ttlDays when you write a blob and it is deleted that many days after upload, anywhere from 1 to 730 days. The option works on put(), copy(), putImage(), multipart uploads and presigned URLs, and every write result or head() call now returns an expiresAt field so you know when a file is due to go.
For blobs you already have, setTtl() changes or clears the TTL in place, on one URL or up to 1,000 at a time, without re-uploading anything. The CLI gets the same control: vercel blob set-ttl and a --ttl-days flag, both shipping in Vercel CLI 65.16.0 and @vercel/blob@2.9.0. Setting a TTL costs one Advanced Operation per started 60 days on top of the write, so a 7-day TTL is one operation and the 730-day maximum is 13. Clearing a TTL and the deletions themselves are free.
Why it matters: temporary exports, signed report downloads and short-lived upload buffers are exactly the kind of thing that quietly pile up in storage until someone writes a cleanup cron job. This replaces that cron job with one extra argument.
import { put } from '@vercel/blob'
await put('exports/report.csv', csv, { ttlDays: 7 })