关于 upload-r2
用于将大型媒体资源上传到 Remotion 公共托管地址的工作流技能,避免将文件提交到 Git。它说明如何使用 R2 凭据和 Bun 的 S3 兼容客户端上传、检查资源并更新本地引用。
主要功能
- 01将资源上传到 parser-media 存储桶
- 02按文件大小检查现有对象
- 03验证公开 URL
- 04替换本地资源引用
适用场景
- 01在 Git 仓库之外托管大型媒体
- 02用托管资源替换本地二进制文件
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ remotion-dev/ remotion --skill upload-r2安装后在 Claude Code 中输入/upload-r2确认已加载。
详细介绍
上传 R2 资源
将大型媒体资源托管到 https://remotion.media/,而不是提交到 Git 时使用此方法。
工作流程
-
找到主工作树:
git worktree list --porcelain优先使用位于
refs/heads/main的工作树,通常是/Users/jonathanburger/remotion。 -
从主工作树加载 R2 凭据:
--env-file=/Users/jonathanburger/remotion/packages/remotion-media/.env不要打印机密值。所需变量为
AWS_ACCESS_KEY_ID和AWS_SECRET_ACCESS_KEY。 -
使用 Bun 的兼容 S3 客户端将文件上传到
parser-media存储桶:bun --env-file=/Users/jonathanburger/remotion/packages/remotion-media/.env -e "import {S3Client} from 'bun'; const filePath='<local-file>'; const key='<remote-file-name>'; const client=new S3Client({accessKeyId:Bun.env.AWS_ACCESS_KEY_ID, secretAccessKey:Bun.env.AWS_SECRET_ACCESS_KEY, endpoint:'https://2fe488b3b0f4deee223aef7464784c46.r2.cloudflarestorage.com', bucket:'parser-media'}); const file=Bun.file(filePath); if (await client.exists(key)) { const stat=await client.stat(key); if (stat.size===file.size) { console.log('exists-same-size', key, file.size); process.exit(0); } } await client.write(key, file); const stat=await client.stat(key); console.log('uploaded', key, stat.size);" -
验证公开 URL:
curl -I --fail https://remotion.media/<remote-file-name> -
将本地资源替换为托管 URL,并删除本地二进制文件。
不要将远程 URL 包装在
staticFile()中:staticFile()不接受http://和https://URL。请直接使用 URL 字符串,例如:<Video src="https://remotion.media/example.mp4" /> -
对修改过的包运行针对性的 lint 或 stylecheck,然后提交并推送。
评论
支持 Markdown