|
|
|
|
|
Brightcove :
Developers :
Media APIs :
Re: Upload video in Flex?
|
|
|
|
|
|
|

|
Re: Upload video in Flex?
|
|
BC-AdamBrod
Brightcove Team
Posts: 6
Registered: 12-11-2008

Message 11 of 56

Viewed 2,904 times
|

|
|
Hi Gregory- The Brightcove Studio uses an internal API to upload videos that won't work with an API token and it isn't supported. However, the reason Flash uploading works for the Studio is because it isn't using JSON, just a regular http request. Http requests aren't as strict with parameter ordering because each parameter is named. If you implement a proxy as recommended above, you can make the post a regular http request and use any parameter order you like. -Adam
|
|
|
|
04-28-2009 08:11 AM
|
|
|
|
|

|
Re: Upload video in Flex?
|
|
Gregory
Regular Contributor
Posts: 54
Registered: 04-21-2009

Message 12 of 56

Viewed 2,892 times
|

|
|
My problem is that my server is limited to 8MB for file upload. I get the headers sent by flash, and the json request is actually before the file : POST /services/post HTTP/1.1 Accept: text/* Content-Type: multipart/form-data; boundary=----------ae0Ij5cH2ae0KM7gL6gL6KM7Ij5cH2 User-Agent: Shockwave Flash Host: api.brightcove.com Content-Length: 2798436 Pragma: no-cache
------------ae0Ij5cH2ae0KM7gL6gL6KM7Ij5cH2 Content-Disposition: form-data; name="Filename"
Butterfly.wmv ------------ae0Ij5cH2ae0KM7gL6gL6KM7Ij5cH2 Content-Disposition: form-data; name="json"
{"method":"create_video","params":{"token":"My write token","video":{"name":"video name","shortDescription":"description","tags":["gibbous","foo"]}}} ------------ae0Ij5cH2ae0KM7gL6gL6KM7Ij5cH2 Content-Disposition: form-data; name="file"; filename="Butterfly.wmv" Content-Type: application/octet-stream
[datas ...] I have the following error message : unable to parse JSON-RPC parameters; they may be malformed or incorrect (code 205) Flash seems to add in first position the file name, but the variable is named ("Filename") so only json parameter should be taken into account.
|
|
|
|
04-28-2009 10:17 AM
|
|
|
|
|

|
Re: Upload video in Flex?
|
|
BC-ChrisTierney
Brightcove Team
Posts: 59
Registered: 12-12-2008

Message 13 of 56

Viewed 2,873 times
|

|
|
Hi Gregory, now that we're aware of the Flash problem we do have an open task to have the API ignore the extra "Filename" parameter. Unfortunately until that fix goes out I don't think there is any workaround other than to use a proxy or not use Flash for the upload. .chris
|
|
|
|
04-28-2009 04:21 PM
|
|
|
|
|

|
Re: Upload video in Flex?
|
|
Gregory
Regular Contributor
Posts: 54
Registered: 04-21-2009

Message 14 of 56

Viewed 2,868 times
|

|
|
Hi Chris, Finally I found a way to upload it using flash and as3httpclientlib and FileReference.load It only works with Flash Player 10 and it's a little bit tricky but it works. I will post my code when it will be clean...
|
|
|
|
04-28-2009 05:10 PM
|
|
|
|
|
|
|
|
|

|
Re: Upload video in Flex?
|
|
Gregory
Regular Contributor
Posts: 54
Registered: 04-21-2009

Message 17 of 56

Viewed 2,846 times
|

|
|
Here is the part of the code to make the post directly using socket, with the following limitations : - user must have flash player 10 installed - the load method of FileRefence is limited to 100MB - there is no way to have feedback because there is no event when uploading files by socket with flash import com.adobe.net.URI; import com.adobe.serialization.json.JSON; import org.httpclient.events.HttpDataListener; import org.httpclient.events.HttpResponseEvent; import org.httpclient.http.multipart.Multipart; import org.httpclient.http.multipart.Part; import org.httpclient.HttpClient; import org.httpclient.Log; private var fileRef:FileReference; private const TOKEN:String = "your write token here"; private const UPLOAD_CALL:String = "http://api.brightcove.com/services/post"; private var listener:HttpDataListener; ........ private function onClick(e:MouseEvent):void { fileRef = new FileReference(); var imagesFilter:FileFilter = new FileFilter("Videos", "*.3g2;*.3gp;*.asf;*.avi;*.flv;*.f4v;*.m4v;*.mov;*.mp4;*.mpeg;*.mpg;*.qt;*.wmv"); fileRef.addEventListener(Event.SELECT, onFileSelectedLocalLoad); fileRef.browse([imagesFilter]); }
private function onFileSelectedLocalLoad(e:Event):void { fileRef.addEventListener(Event.COMPLETE, onLocalLoadComplete); fileRef.load(); } private function onLocalLoadComplete(e:Event):void { Log.level = Log.DEBUG; var charles:URI; // uncomment to use Charles debugging proxy // charles = new URI("http://localhost:8888"); var http:HttpClient = new HttpClient(charles, 600000); var uri:URI = new URI(UPLOAD_CALL); var jsonParams:Object = new Object(); jsonParams.method = "create_video"; jsonParams.params = { token:TOKEN, video:{name:fileRef.name, shortDescription:"Test video", tags:["gibbous","foo"]}}; var multipart:Multipart = new Multipart([new Part('json', JSON.encode(jsonParams)), new Part('file', fileRef.data, "video/octet-stream", [ { name:"filename", value:fileRef.name } ])]); listener = new HttpDataListener(); listener.onComplete = onPostComplete; listener.onDataComplete = onPostDataComplete; http.listener = listener; http.postMultipart(uri, multipart); }
private function onPostComplete(event:HttpResponseEvent):void{ trace(event); trace(event.response); }
|
|
|
|
04-29-2009 04:53 AM
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|