Newshot

Vercel Blob 现已支持 TTL 自动删除

AI summary

Vercel Blob 现在可以自动删除 blob:写入时传入 ttlDays,该 blob 就会在上传后的指定天数(1 至 730 天)被删除,TTL 从上传日期起算。ttlDays 适用于 put()、copy()、putImage()、分片上传和预签名上传 URL,每次写入结果和 head() 响应都会包含 expiresAt;setTtl() 可在不重新上传的情况下修改或移除已有 blob 的 TTL,支持单个 URL 或一次最多 1,000 个。Vercel CLI 65.16.0 及更高版本中,可为 vercel blob put、put-image、copy 或 presign 传入 --ttl-days,并对已有 blob 使用 vercel blob set-ttl。设置 TTL 除写入费用外,每开始一个 60 天计一次 Advanced Operation:7 天 TTL 计一次,730 天上限计 13 次;清除 TTL 和删除本身免费。

Translation(model translation, not the source's own text)

Vercel Blob 现在可以自动删除 blob。在写入 blob 时传入 ttlDays,它就会在上传后的相应天数被删除,可设范围为 1 到 730 天。TTL 从 blob 的上传日期开始计算。

对于那些本来需要你自己删除的 blob,可以使用 TTL,例如会话记录、导出文件和临时上传。

ttlDays 适用于 put()、copy()、putImage()、分片上传以及预签名上传 URL。现在每个写入结果和 head() 响应都会包含 expiresAt,因此你可以知道某个 blob 何时会被删除。


        import { put, setTtl } from '@vercel/blob';
// Delete this export 7 days after uploadconst blob = await put('exports/report.csv', csv, {  access: 'private',  ttlDays: 7,});
console.log(blob.expiresAt); // 2026-11-24T00:00:00.000Z
// Change your mind later: extend to 30 days, or clear it with nullawait setTtl(blob.url, { ttlDays: 30 });await setTtl(blob.url, { ttlDays: null });
      

setTtl() 可以修改或移除你已有 blob 的 TTL,支持单个 URL,也支持一次最多 1,000 个,无需重新上传。

在 Vercel CLI 65.16.0 及更高版本中,可以为 vercel blob put、put-image、copy 或 presign 传入 --ttl-days,并对已有 blob 使用 vercel blob set-ttl。


        vercel blob put report.csv --ttl-days 7vercel blob set-ttl exports/a.csv exports/b.csv --ttl-days 30vercel blob set-ttl exports/a.csv --clear-ttl
      

设置 TTL 除了写入费用外,每开始计算的 60 天收取一次 Advanced Operation 费用。7 天的 TTL 收取一次,730 天的上限收取 13 次。清除 TTL 和删除操作本身免费。你可以在 Observability 标签页的 Blob 部分跟踪 TTL 操作。

npm install @vercel/[email protected]

在 Vercel Blob 文档中了解更多。

The translation is machine-generated and individual terms may be off. Nothing is rewritten or cut; the original is authoritative.

Published by Vercel Blog
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗