mcpField
U
upload-r2

upload-r2

github.com/remotion-dev云与 DevOps68.6k594 次安装今天更新
代码仓库

关于 upload-r2

用于将大型媒体资源上传到 Remotion 公共托管地址的工作流技能,避免将文件提交到 Git。它说明如何使用 R2 凭据和 Bun 的 S3 兼容客户端上传、检查资源并更新本地引用。

主要功能

  1. 01将资源上传到 parser-media 存储桶
  2. 02按文件大小检查现有对象
  3. 03验证公开 URL
  4. 04替换本地资源引用

适用场景

  1. 01在 Git 仓库之外托管大型媒体
  2. 02用托管资源替换本地二进制文件

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/remotion-dev/remotion --skill upload-r2

安装后在 Claude Code 中输入/upload-r2确认已加载。

详细介绍

上传 R2 资源

将大型媒体资源托管到 https://remotion.media/,而不是提交到 Git 时使用此方法。

工作流程

  1. 找到主工作树:

    git worktree list --porcelain
    

    优先使用位于 refs/heads/main 的工作树,通常是 /Users/jonathanburger/remotion。

  2. 从主工作树加载 R2 凭据:

    --env-file=/Users/jonathanburger/remotion/packages/remotion-media/.env
    

    不要打印机密值。所需变量为 AWS_ACCESS_KEY_ID 和 AWS_SECRET_ACCESS_KEY。

  3. 使用 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);"
    
  4. 验证公开 URL:

    curl -I --fail https://remotion.media/<remote-file-name>
    
  5. 将本地资源替换为托管 URL,并删除本地二进制文件。

    不要将远程 URL 包装在 staticFile() 中:staticFile() 不接受 http:// 和 https:// URL。请直接使用 URL 字符串,例如:

    <Video src="https://remotion.media/example.mp4" />
    
  6. 对修改过的包运行针对性的 lint 或 stylecheck,然后提交并推送。

评论

支持 Markdown