Upload video from java

48 views
Skip to first unread message

Makism

unread,
Oct 11, 2010, 6:29:04 PM10/11/10
to Panda
I'm building Java client that will automatically upload file from Java
server to Panda Instance that I installed on my EC2 cloud using your
AMI. I'm trying to use Apache HTTP Components (http://hc.apache.org/
httpcomponents-client-ga/index.html) to upload to Panda Server. It
works fine with my browser client but for some reason I can't upload
from that library. Here is my code:

---------------- CLIENT CODE START -----------

String videoUploadUrl = "http://[panda server ip]/videos/" +
getVideoID() + "/upload.xml";
File file = new File("/temp/videofile.mp4");

DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
HttpVersion.HTTP_1_1);

HttpPost httppost = new HttpPost(videoUploadUrl);

MultipartEntity mpEntity = new MultipartEntity();

ContentBody fBody = new FileBody(file);

mpEntity.addPart("userfile", fBody);

httppost.setEntity(mpEntity);


System.out.println("executing request " + httppost.getRequestLine());
HttpResponse response2 = httpclient.execute(httppost); // <-- FAILS
HERE
System.out.println("finish executing request");

HttpEntity resEntity = response2.getEntity();

System.out.println(response2.getStatusLine());
if (resEntity != null) {
System.out.println(EntityUtils.toString(resEntity));
}
if (resEntity != null) {
resEntity.consumeContent();
}

httpclient.getConnectionManager().shutdown();
-------------------- CLIENT CODE END --------------

And here is my error log.

----------------- ERROR LOG BEGIN -----------
executing request POST http://[panda server id]/videos/0fbd7300-
b7b2-012d-7c3f9-1223456a654/upload.xml HTTP/1.1 Method: POST
Oct 11, 2010 3:09:25 PM
org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (java.net.SocketException) caught when processing
request: Broken pipe
Oct 11, 2010 3:09:25 PM
org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
Oct 11, 2010 3:09:55 PM
org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (java.net.SocketException) caught when processing
request: Broken pipe
Oct 11, 2010 3:09:55 PM
org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
Exception in thread "main" java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at
java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:
136)
at
org.apache.http.impl.io.AbstractSessionOutputBuffer.write(AbstractSessionOutputBuffer.java:
124)
at
org.apache.http.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:
114)
at
org.apache.http.entity.mime.content.FileBody.writeTo(FileBody.java:
105)
at
org.apache.http.entity.mime.HttpMultipart.doWriteTo(HttpMultipart.java:
173)
at
org.apache.http.entity.mime.HttpMultipart.writeTo(HttpMultipart.java:
191)
at
org.apache.http.entity.mime.MultipartEntity.writeTo(MultipartEntity.java:
169)
at
org.apache.http.impl.entity.EntitySerializer.serialize(EntitySerializer.java:
120)
at
org.apache.http.impl.AbstractHttpClientConnection.sendRequestEntity(AbstractHttpClientConnection.java:
253)
at
org.apache.http.impl.conn.AbstractClientConnAdapter.sendRequestEntity(AbstractClientConnAdapter.java:
227)
at
org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:
248)
at
org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:
123)
at
org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:
623)
at
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:
455)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:
694)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:
625)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:
603)
at testmainjava.FileUpload.main(FileUpload.java:57)
-------------------- ERROR LOG END ---------------


What am I missing? Why I'm getting broken pipe. If I use same code to
upload to some servlet then I work fine but not with panda Instance.
Any idea?

Damien Tanner

unread,
Oct 12, 2010, 10:35:09 AM10/12/10
to panda...@googlegroups.com
Hi,

Unfortunately I'm not sure we're able to help much. The AMI api is fairly old and we're not Java experts.

Have you taken a look at the new hosted service?

Damien Tanner Damien Tanner - Co-Founder and Director, Panda
+44 (0)20 7099 7486 - pandastream.com - @pandastream
Try our new Realtime web service: http://pusherapp.com

Damien Tanner
Co-Founder and Director, Panda

http://www.pandastream.com



--
You received this message because you are subscribed to the Google Groups "Panda" group.
To post to this group, send email to panda...@googlegroups.com.
To unsubscribe from this group, send email to pandastream...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pandastream?hl=en.


Reply all
Reply to author
Forward
0 new messages