Question

I want to upload a video from an HTML form directly to Brightcove. We run Coldfusion 9 on our servers.

I can find instructions on uploading the video to my local server like this:

<cffile action="upload" nameconflict="makeunique" filefield="form.video_file" destination="#upload_path#" result="uploaded_file">

... and instructions on uploading a video from my local server to Brightcove like this:

<cfhttp url="#variables.apiBaseUrl#" method="post"  timeout="#variables.timeout#" result="resultVar" multipart="true">
    <cfhttpparam type="formfield" name="json" VALUE = "#arguments.jsonArgs#">
    <cfhttpparam type="file" name="#getFileFromPath(arguments.filename)#" file="#arguments.filename#"/>
</cfhttp>

But not from the HTML form directly to Brightcove.

Is this possible?

Thanks! Nick

Was it helpful?

Solution

There are examples of how to upload directly from the browser to Brightcove in their JavaScript Media API Examples.

But, as the documentation notes, what you want to accomplish is not recommended for a few reasons:

  • Some browsers such as IE9 will prompt you to download the response rather than show it in the form because the browser doesn't know what to do with the mime type.
  • It's not good practice to expose an API token on the form, as noted in the examples' source code.
  • Client-side Media API calls are not recommended as a UGC upload solution because of the lack of security.

If you're finding that the process for uploading to your server then to Brightcove is taking too long, you'll probably want to build a queue system.

  1. The user waits on the browser to upload to your server.
  2. Your server stores the file somewhere temporarily and adds a task to a database table storing queued tasks.
  3. The user sees that the video is "pending" while it's still enqueued.
  4. A scheduled task periodically checks the queue table and uploads the tasks one at a time. Once a task is done, it updates the video to be "ready."
  5. The user sees that the video is ready.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top