Media APIs
Register  ·  Sign In  ·  Help
Jump to Page:   1 · 2 · 3 · 4 · 5 · 6  |  Next Page
  Reply   Reply  

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


BC-AdamBrod

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 

Kudos!
04-28-2009 08:11 AM
  Reply   Reply  

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


Gregory

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.

 

Kudos!
04-28-2009 10:17 AM
  Reply   Reply  

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


BC-ChrisTierney

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

Kudos!
04-28-2009 04:21 PM
  Reply   Reply  

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


Gregory

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...

1
Kudos!
04-28-2009 05:10 PM
  Reply   Reply  

Re: Upload video in Flex?
Options    Options  
BC-Sean
Brightcove Team
Posts: 76
Registered: 01-09-2009


BC-Sean

Message 15 of 56

Viewed 2,864 times


Thanks that would be a gret example to have!
Kudos!
04-28-2009 05:13 PM
  Reply   Reply  

Re: Upload video in Flex?
Options    Options  
ebeyrent
Visitor
Posts: 7
Registered: 03-13-2009


ebeyrent

Message 16 of 56

Viewed 2,854 times


Very exciting - I look forward to seeing what you came up with!
Kudos!
04-28-2009 09:22 PM
  Reply   Reply  

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


Gregory

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);

}

 

3
Kudos!
04-29-2009 04:53 AM
  Reply   Reply  

Re: Upload video in Flex?
Options    Options  
ebeyrent
Visitor
Posts: 7
Registered: 03-13-2009


ebeyrent

Message 18 of 56

Viewed 2,840 times


When you say that there is no way to have feedback, does that mean that you don't get a response back from Brightcove with the details about the uploaded video, such as the video id?
Kudos!
04-29-2009 07:11 AM
  Reply   Reply  

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


Gregory

Message 19 of 56

Viewed 2,838 times


No, it does just mean that there is no progress event. I cannot display a progress bar with loaded bytes but the complete event is called at the end of the transfer, and the json response can be parsed.
1
Kudos!
04-29-2009 08:19 AM
  Reply   Reply  

Re: Upload video in Flex?
Options    Options  
WundermanNY
New Member
Posts: 2
Registered: 03-27-2009


WundermanNY

Message 20 of 56

Viewed 2,826 times


Why is Flash Player 10 required?
Kudos!
04-29-2009 10:56 AM
Jump to Page:   1 · 2 · 3 · 4 · 5 · 6  |  Next Page