I am developing locally and am trying to transfer large videos from R2 to Stream and hitting the siz

I am developing locally and am trying to transfer large videos from R2 to Stream and hitting the size limit issue.

What would be the best way to handle this? can you actually send a tus request via worker without a browser? Would this work on server?

https://developers.cloudflare.com/stream/uploading-videos/resumable-uploads/

Or is should I create a R2 link via S3 only on a real R2 bucket, because I don't think we can do this on local testing??
https://developers.cloudflare.com/stream/uploading-videos/upload-via-link/
https://developers.cloudflare.com/r2/examples/aws/aws4fetch/#generate-presigned-urls


// Get the video from R2
const videoR2 = await this.env.COVE_STORAGE.get(
    `${video.organizationId}/${video.id}`,
);
if (!videoR2 || !videoR2.httpMetadata) {
    throw new NonRetryableError("Video not found in storage.");
}

// Upload the video from R2 to Cloudflare Stream
const formData = new FormData();
formData.append(
    "file",
    new Blob([await videoR2.blob()]),
    `${video.organizationId}/${video.id}`,
);

const streamResponse = await fetch(streamEndpoint, {
    method: "POST",
    headers: {
        Authorization: `Bearer ${this.env.CLOUDFLARE_API_TOKEN}`,
        // No Content-Type header - FormData will set it automatically with the boundary
    },
    body: formData,
});
Was this page helpful?