mcpField
U
upload-r2

upload-r2

github.com/remotion-devCloud & DevOps68.6k594 installsUpdated today
Repository

About upload-r2

A workflow skill for uploading large media assets to Remotion's public media hosting instead of committing them to Git. It describes the steps for using R2 credentials and Bun's S3-compatible client, checking the hosted asset, and updating local references.

Key features

  1. 01Upload assets to the parser-media bucket
  2. 02Check for existing objects by size
  3. 03Verify public URLs
  4. 04Replace local asset references

Use cases

  1. 01Hosting large media outside a Git repository
  2. 02Replacing a local binary with a hosted asset

Install

Copy the command and run it in a terminal.

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

After installing, type/upload-r2in Claude Code to confirm it loaded.

Details

From the project README

Upload R2 Asset

Use this for large media assets that should be hosted on https://remotion.media/ instead of committed to Git.

Workflow

  1. Find the main worktree:

    git worktree list --porcelain
    

    Prefer the worktree on refs/heads/main, usually /Users/jonathanburger/remotion.

  2. Load R2 credentials from the main worktree:

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

    Do not print secret values. The required variables are AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

  3. Upload the file to the parser-media bucket using Bun's S3-compatible client:

    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. Verify the public URL:

    curl -I --fail https://remotion.media/<remote-file-name>
    
  5. Replace local asset usage with the hosted URL and delete the local binary.

    Do not wrap remote URLs in staticFile(): staticFile() rejects http:// and https:// URLs. Use the URL string directly, for example:

    <Video src="https://remotion.media/example.mp4" />
    
  6. Run the focused lint or stylecheck for touched packages, then commit and push.

Comments

Markdown supported