Streaming large file from Object Storage

Hello,
Is it possible to stream large files through Worker? i am hosting some videos on an object storage service. the link for video on object storage is like this la.server562.domain.com/p/some_random_letters/bucket_name/video.mp4
I want to change it to my domain like this
media.mydomain.com/p/some_random_letters/bucket_name/video.mp4
I use the script below but video buffers for 30 sec to 1 min, cannot fast forward and the video stops completely after few minutes of play.
I truly appreciate any help

async function handleRequest(request) {
const parsedUrl = new URL(request.url)
let path = parsedUrl.pathname
let lastSegment = path.substring(path.lastIndexOf('/'))
if (lastSegment.indexOf('.') === -1) {
path += '/index.html'
}
return fetch("https://la.server562.domain.com" + path)
}
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})

Workers aren’t built for this, there’s a separate video streaming product.

I don’t need CF to host my videos. I want to use it as proxy. other users use workers for similar video project. thanks anyway
for your reference : https://support.cloudflare.com/hc/en-us/articles/360013791312-Fetching-object-storage-assets-through-the-Cloudflare-CDN-using-a-Cloudflare-Worker

Problem is, the workers are per-request, the process don’t live long enough for you to view the video.

1 Like