$npx -y skills add remotion-dev/remotion --skill upload-r2Upload large Remotion repository assets to the Cloudflare R2 bucket behind remotion.media and replace local public/ assets with hosted URLs. Use when a file is too large for Git or when a PR should avoid committing media binaries by hosting them on remotion.media.
| 1 | # Upload R2 Asset |
| 2 | |
| 3 | Use this for large media assets that should be hosted on `https://remotion.media/` instead of committed to Git. |
| 4 | |
| 5 | ## Workflow |
| 6 | |
| 7 | 1. Find the main worktree: |
| 8 | ```bash |
| 9 | git worktree list --porcelain |
| 10 | ``` |
| 11 | Prefer the worktree on `refs/heads/main`, usually `/Users/jonathanburger/remotion`. |
| 12 | |
| 13 | 2. Load R2 credentials from the main worktree: |
| 14 | ```bash |
| 15 | --env-file=/Users/jonathanburger/remotion/packages/remotion-media/.env |
| 16 | ``` |
| 17 | Do not print secret values. The required variables are `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`. |
| 18 | |
| 19 | 3. Upload the file to the `parser-media` bucket using Bun's S3-compatible client: |
| 20 | ```bash |
| 21 | 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);" |
| 22 | ``` |
| 23 | |
| 24 | 4. Verify the public URL: |
| 25 | ```bash |
| 26 | curl -I --fail https://remotion.media/<remote-file-name> |
| 27 | ``` |
| 28 | |
| 29 | 5. Replace local asset usage with the hosted URL and delete the local binary. |
| 30 | |
| 31 | Do not wrap remote URLs in `staticFile()`: `staticFile()` rejects `http://` and `https://` URLs. Use the URL string directly, for example: |
| 32 | ```tsx |
| 33 | <Video src="https://remotion.media/example.mp4" /> |
| 34 | ``` |
| 35 | |
| 36 | 6. Run the focused lint or stylecheck for touched packages, then commit and push. |