RuiAlmeida's avatar

Make a progress bar when uploading to Vimeo

I'm using the package https://github.com/vinkla/vimeo

The process to upload the video its working with this code:

 $upload = Vimeo::upload($request->file('file'));

I need to give some information to a user that is uploading, perhaps a progress bar. But i have no clue how to build that.

The oficial documentation says: https://developer.vimeo.com/api/upload/videos#verify-the-upload

To check how much of a file has transferred, perform the exact same PUT request without the file data and with the header "Content-Range: bytes */*". Here’s an example reques

Host: 1.2.3.4:8080
Content-Length: 0
Content-Range: bytes */*

If anyone can give me some tip or a link that i can learn how to make it happen, would be awesome.

0 likes
4 replies
RuiAlmeida's avatar

Hey, I suspended this project. So i dont have finished/production code. But i had it work with help on other site http://stackoverflow.com/questions/32618832/how-to-make-a-progress-bar-when-uploading-to-vimeo If your read the comments you probably figure out how it can be handled. If you need more help let me know, and TRY help you :) BTW Its ridiculous that we have to break so much stone to handle such a basic feature. It should be more easy.

RuiAlmeida's avatar

It seems to be easier now.

Have a look here https://github.com/vimeo/vimeo.js#uploading-videos

Using the progressCallback function apparently you can calculate the progress bar

client.upload(
  '/home/aaron/Downloads/ada.mp4',
  function (uri) {
    console.log('File upload completed. Your Vimeo URI is:', uri)
  },
  function (bytesUploaded, bytesTotal) {
    var percentage = (bytesUploaded / bytesTotal * 100).toFixed(2)
    console.log(bytesUploaded, bytesTotal, percentage + '%')
  },
  function (error) {
    console.log('Failed because: ' + error)
  }
)

Please or to participate in this conversation.