Skip to main content

自动删除渲染

从 v4.0.32 起可用

🌐 available from v4.0.32

要在一段时间后自动删除渲染及相关文件,你需要:

🌐 To automatically delete renders and associated files after some time, you need to:

在 AWS 存储桶上启用生命周期规则。
2
使用 deleteAfter 选项渲染视频。

应用生命周期规则

🌐 Apply the lifecycle rules

1
确保正确的权限

要在桶上设置生命周期规则,你需要为你的用户拥有 s3:PutLifecycleConfiguration 权限。

🌐 To put a lifecycle rule on the bucket, you need to have the s3:PutLifecycleConfiguration permission for your user.

  • 如果你在 4.0.32 之后设置 Remotion Lambda,你就会自动拥有它。
  • 如果你之前设置过 Remotion Lambda,请执行以下操作:
    1. 升级到至少 Remotion 4.0.32。
    2. 点击这里 进入 AWS 控制台的用户部分。
    3. 选择你的用户。
    4. 在“权限策略”下,点击你的策略(蓝色下划线)
    5. 选择“JSON”模式进行编辑。
    6. "Sid": "Storage" 部分,将 "s3:PutLifecycleConfiguration" 添加到 "Action" 数组中。
    7. 保存。

2
启用生命周期规则

使用 --enable-folder-expiry 选项重新部署站点。此操作将修改 S3 存储桶以应用 AWS 生命周期规则

🌐 Redeploy the site with the --enable-folder-expiry option. This operation will modify the S3 bucket to apply AWS Lifecycle Rules.

In the command line
npx remotion lambda sites create --site-name=my-site-name --enable-folder-expiry
验证它是否有效

在你的 S3 桶中,在“管理”下,你应该看到 4 条生命周期规则。


触发带有过期时间的渲染

🌐 Trigger a render with expiration

有效值是 "1-day""3-days""7-days""30-days"

🌐 Valid values are "1-day", "3-days", "7-days" and "30-days".

npx remotion lambda render testbed-v6 react-svg --delete-after="1-day"

验证它是否有效

在查看对象属性时,所有文件都应设置过期规则和过期日期。



AWS 不会在确切的时间删除文件,但删除会发生。

🌐 AWS does not delete the file at the exact time, but the deletion will happen.

它是如何运作的

🌐 How it works

通过应用 AWS 生命周期规则,我们指示 AWS S3 根据其前缀删除文件。当 deleteAfter 被定义为 "1-day" 值时,renderId 将以 1-day 为前缀,并且 S3 键将以 renders/1-day-* 开头,对其应用删除规则。删除的依据是文件/文件夹的 Last modified date

🌐 By applying the AWS Lifecycle rules, we are instructing AWS S3 to delete files based on their prefixes. When deleteAfter is defined with a value of "1-day", the renderId will be prefixed with 1-day, and the S3 key will start with renders/1-day-*, to which the deletion rule will be applied.
The basis of the deletion is based on the Last modified date of the file/folder.

deleteAfter

渲染前缀

1天renders/1-day
3天renders/3天
7天渲染/7天
30天渲染/30天

另请参阅

🌐 See also