Introduction

A video upload feature is commonly implemented inside applications. Solutions are often simple, but not straightforward. Problems happen when you consider a video upload feature from mobile and face constraints such as connection to server timeout on upload and pure network bandwidth on streaming.

The first option we considered was to use an external service for video storage and handle other aspects of video upload on our back-end application with a custom implementation. The best-fit service, in this case, is Amazon S3. On the other hand, we also considered using a complete service that will host our videos but also handle upload, processing/converting, and streaming.

Initially, we tried the first option and ended up with a lot of problems regarding very long processing times, since our machines were not specialized in video conversion and were slow in streaming to mobile applications. This caused very strict limitations for video size, even when the mobile applications were using fast networks. We could have used some other Amazon service to resolve this problem, but we decided to try a complete solution instead and chose Vimeo.

Upload process with Vimeo

Vimeo supports post, streaming, and pull methods. We chose streaming because it provides the most flexibility for tailoring the upload process to your application needs.



The first thing you need to do after creating a Vimeo account is to go to developer.vimeo.com/apps, choose your application, and click ‘Request upload access’. This can take a couple of days to become operational, so be sure to do this well before your deadline. Once you have successfully gained upload access you can proceed with choosing your preferred upload method.

Vimeo API supports three upload methods: post, streaming, and pull (automatic).

We chose the streaming approach for both our mobile and web applications because it provides more options for tailoring the upload flow to suit your application needs.

The streaming approach goes through five stages:

1. Check quota.

2. Get ticket.

3. Upload video.

4. Check if the video is fully uploaded.

5. Delete upload ticket.

Before starting this process you need to generate a ‘personal access token’ by going to developer.vimeo.com/apps and choosing your application. Under the Authentication tab you’ll see a list of access tokens and options for generating a new one. Under Scopes you need to choose public, private, upload, and edit. The first three are straight forward; we’ll see why we need to edit down the road.

In our case we jumped straight to the second step, since we already use a business Vimeo account with no upload limit. If you use a free, plus, or pro account you should first check if your upload limit has been reached. We also skipped the step that involves checking if the video is fully uploaded since our upload flow didn’t need a feature of continuing upload for partially uploaded video.

Snippets for Android will be written using the Retrofit library, which we use in order to consume REST APIs. Snippets are written in Java and for parsing of JSON we will use the Jackson library.

Snippets for iOS will be written in Objective-C, using just the Foundation framework without any external libraries.