Search code examples
node.jsvimeovimeo-apibusboy

Uploading videos using vimeo


I'm implementing uploading videos to vimeo using the official vimeo library. The problem is that I upload the whole video to the server and only then send it to vimeo. After sending I clean it up, of course, but videos can weight a few gbs, so it's a problem. I'm using async-busboy to save data, tmp to create temporary files. I want to send chunks to my server and upload them to vimeo at the same time, because storing the whole videos can break my server. I need to feed to vimeo a steam somehow.

The thing is vimeo uploads videos by chunks, but you must feed it the whole one when you start. I'm also considering library called vimeo-chunk-upload to upload directly from the front end, but I'll have to store private key in code and that is not safe.

const { files } = await Busboy(request);

const clip = files[0].pipe(fs.createWriteStream(pathname))

clip.on('finish', () => {
  vimeo.upload(pathname, ...)
})

The back end implementation causes a lot of problems, but it's safe. If there is a way to upload using chunks to my server, I can proceed. Otherwise, I need to know how to make it safe on the front end, because this approach is so much easy.


Solution

  • You can generate the video link at your backend server while you can upload the video at the frontend itself. This approach will secure your access token as well as will reduce the load of backend server.

    According to https://developer.vimeo.com/api/upload/videos you need your access token only while generating the video link and not while uploading it.

    Hope this helps!