[The following article on video upload is based on vdocipher API v2 which is the latest version]
We use Amazon aws storage to store original user videos securely in AWS S3. With an intent to automate their online business, many of our customers wish to allow their users to upload videos directly from their website. To enable this, we have a API call that returns an authenticated policy document which is used video upload into a S3 bucket allotted to your account.
Step 1 (Obtain authorized access):
Create authorized video upload request with your API secret key.
Content type: application/x-www-form-urlencoded
The API call has returned a set of parameters that must go with the video upload call to the AWS S3 endpoint. We shall refer to this JSON object returned above as uploadData.
The policy document is valid only for the next 1 hour. It is recommended to make the video upload immediately after creating the authorized access. There is also a soft restriction on the number of upload calls every hour, so it is advised to create it only after the user has chosen to upload the video. It should not be made every time somebody loads their dashboard or mobile app.
This call must be made from a secure environment such as your server. This should not be called from a mobile device or the browser to protect your API key. The uploadData should then be passed to user’s device (mobile or browser) to do the file upload.
Step 2 (Video upload via S3 API):
Upload the file to amazon s3 directly. This upload can be made using server code or using an HTML5 form. You can use any third party upload library to make the upload script. The famous ones already have tutorials on setting it up with S3 upload.
'x-amz-date' : uploadData['x-amz-date'],
key : uploadData['key'],
policy : uploadData['policy'],
success_action_status : 201,
success_action_redirect : 'http://example.com'
file: <file content>
- upload_link_secure string – The vdocipher storage location on S3 that has been allocated for this file
- x-amz-credential string – These must be accompanied in the upload request.
- x-amz-algorithm string
- x-amz-date string
- x-amz-signature string – A signature value that authorizes the form and proves that only vdocipher could have created it.
- key string – A name for the S3 object that will store the uploaded file’s data
- policy string – authorization string
- success_action_status integer – The status code returned upon successful upload if success_action_redirect is not specified.
- success_action_redirect string(optional) – Specifies if to redirect to a URL after a successful post instead of issuing a 201.
If everything goes right, the response from the above request should be:
<?xml version="1.0" encoding="UTF-8"?>
You can ignore the content of this response. Now, the video status should be shown as Queued or Processing in the API or on your dashboard. The video will get processed after some time. You can poll the API or configure the web hooks(coming soon) to know the time when video is ready. You should only load the video player if the video is ready.
Some sample code for the above operations: