-
Notifications
You must be signed in to change notification settings - Fork 6
2 Video uploading
There are three ways to transfer the video data to Vimeo: POSTing the file, streaming the file, or letting Vimeo download the file from your server. Which approach you choose depends on the capabilities of the environment you’re working in and your level of comfort with network programming. Here are some considerations:
- Post: This is the simplest integration; it allows your users to upload directly to Vimeo using a standard HTML form and bypass your server entirely. But if there are any network connectivity errors, the user will have to retry the entire upload. And you can't display a progress bar.
- Streaming: This is better if you have a more integrated app (like mobile) and want more robust handling of connectivity issues, providing your users with pause, progress bars, and resume. You also have the option to use client-side JavaScript (with the HTML5 File object) to perform and verify the upload, which shifts this work from your server to the user's browser. But streaming is also the most complex approach.
- Automatic ("Pull"): This is the best (and easiest) approach if the video is already posted on the Internet, at a URL accessible by Vimeo's upload server. All you need to do is provide us with the URL, and we'll automatically grab ("pull") it (and transparently handle any connectivity issues that might arise).
Please, read more about Vimeo Video Uploading from the official documentation
Simple video POSTing can be done in an easy manner
Vimeo.video.create_by_posting('https://your_redirect.url.here')
In the response you will get all data which is necessary for video uploading (user form and action endpoints). Refer to the https://developer.vimeo.com/api/upload/videos#simple-upload for the details
https://developer.vimeo.com/api/upload/videos#pull-uploads
Vimeo.video.create_by_pulling('https://link_to_your_video')
Streaming upload is more complicated that the rest ones but we tried to implement it in the most easy way for you
Vimeo.video.create_by_streaming
The response will provide you with a upload secure link that will be required for video upload and complete uri, which will be required for completing the upload process
Vimeo.video.upload_by_streaming('/path/to/video.file', upload_link_secure: 'http://upload/secure.link')
Vimeo.video.verify_upload_by_streaming(upload_link_secure: 'http://upload/secure.link')
If the upload verification shows that Vimeo service did not get bytes from your video you can resume the uploading process from the broken point.
Vimeo.video.upload_by_streaming('/path/to/video.file', upload_link_secure: 'http://upload/secure.link', offset: 1000)
Where the offset is a number of successfully received bytes
Vimeo.video.finish_upload_by_streaming(complete_uri: 'http://complete.url')
You can use all methods above on your own, however the simplest way looks as follows
file_url = '/path/to/video.file'
ticket = Vimeo.video.create_by_streaming
Vimeo.video.upload_by_streaming(file_url, ticket)
Vimeo.video.verify_upload_by_streaming(ticket)
Vimeo.video.finish_upload_by_streaming(ticket)
All this stuff is gathered in a single method
Vimeo.video.stream('/path/to/video.file')
By default this action performs 3 retries to upload data if there where some network or other issues. You can change this by setting options
Vimeo.video.stream('/path/to/video.file', tries: 5)