Back to Remotion

uploadToVercelBlob()

packages/docs/docs/vercel/upload-to-vercel-blob.mdx

4.0.4572.2 KB
Original Source

uploadToVercelBlob()<AvailableFrom v="4.0.426" />

:::warning Experimental package: We reserve the right to make breaking changes in order to correct bad design decisions until this notice is gone. :::

Uploads a file from the sandbox to Vercel Blob storage. Typically used after renderMediaOnVercel() or renderStillOnVercel() to make the output publicly accessible.

Example

ts
// @module: es2022
// @target: es2022
import {uploadToVercelBlob, addBundleToSandbox, createSandbox} from '@remotion/vercel';
const sandbox = await createSandbox();
await addBundleToSandbox({sandbox, bundleDir: '/path/to/bundle'});
// ---cut---
const {url, size} = await uploadToVercelBlob({
  sandbox,
  sandboxFilePath: '/tmp/video.mp4',
  contentType: 'video/mp4',
  blobToken: process.env.BLOB_READ_WRITE_TOKEN!,
  access: 'public',
});

console.log(`Uploaded ${size} bytes to ${url}`);

Arguments

An object with the following properties:

sandbox

A Sandbox instance.

sandboxFilePath

The path to the file inside the sandbox to upload, e.g. "/tmp/video.mp4".

blobPath?

The destination path in Vercel Blob, e.g. "renders/abc.mp4". If omitted, a random path is generated.

contentType

The MIME type of the file, e.g. "video/mp4" or "image/png".

blobToken

Your Vercel Blob read/write token. Typically process.env.BLOB_READ_WRITE_TOKEN.

access

<TsType type="VercelBlobAccess" source="@remotion/vercel" href="/docs/vercel/types#vercelblobaccess" />

The access level of the uploaded blob. Either "public" or "private". Default: "private".

Return value

An object containing:

url

The public download URL of the uploaded file.

size

The size of the uploaded file in bytes.

See also