I'm writing GWT application where I need to upload video file and encode that video into different video formats. I've decided to use Panda Video Converter. I was able to run panda on my EC2 instance (using their image) and I can upload video from Panda's test pages but now I'm trying to make same thing with my own application in GWT. The question that I have is: How do I get Video id and how do I post my video to the server. What URL do I need to use for that? I tried to read their documentation but have no clue where to start. This is my fist time working with webservices and url, probably that's why I don't how it works.
Disclaimer: I have no idea how the Panda Video Converter works, this is just an example of using RequestBuilder
to make GET and POST requests to a server.
The steps to accomplish this seem to be roughly:
- Send a POST to
hq.pandastream.com/videos.(yaml|xml)
with your account ID as a parameter. - Receive a response including the ID of the new video you've created (a placeholder)
- Display a form to the user based on the ID. The form is retrieved by sending a GET to
upload.pandastream.com/videos/[id]/form
- Submitting this form uploads the video, whose information can be retrieved by sending a GET to
GET hq.pandastream.com/videos/id.(yaml|xml)
Since the only elements of this process are POST and GET requests, you can use the RequestBuilder to make these requests for you in GWT.
We'll go through step by step.
Send a POST to hq.pandastream.com/videos.xml
with your account ID as a parameter.
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, "http://hq.pandastream.com/videos.xml");
rb.sendRequest("account_key=foo", new RequestCallback() {
protected void onResponseReceived(Request request, Response, response) {
// parse XML to get "id" element
}
// onError() ...
});
Now that you have the ID, you can make another request to get the upload form HTML.
rb = new RequestBuilder(RequestBuilder.GET, "http://upload.pandastream.com/videos/" + id + "/form");
rb.sendRequest(null, new RequestCallback() {
protected void onResponseReceived(Request request, Response, response) {
// this may not work, and it may be a bad idea to inject third-party HTML
// straight into your page. You might also want to open a popup window
// instead of injecting the HTML directly.
someWidget.setHTML(response.getText());
}
// onError() ...
});
With that form, the user uploads the video, etc.
Now, to get info about the video, it's -- you guessed it -- another RequestBuilder
call.
rb = new RequestBuilder(RequestBuilder.GET, "http://hq.pandastream.com/videos/" + id + ".xml");
rb.sendRequest(null, new RequestCallback() {
protected void onResponseReceived(Request request, Response, response) {
// parse response XML to get info you want
}
// onError() ...
});
Another disclaimer: This is a very rough outline of what appears to be the process of uploading a video, based on the docs you linked. This just serves as a basic example of using RequestBuilder
to make GET/POST calls.
Hi Maksim,
I just wanted to see if you had worked this out. If you need some more help with the open source version feel free to ask on the Google Groups list we have: http://groups.google.com/group/pandastream
You might also be interested in trying out the hosted version we launched publicly last week: http://pandastream.com/