{"id":6204,"date":"2014-04-13T22:40:18","date_gmt":"2014-04-13T22:40:18","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/13\/upload-video-file-using-httpclient-collection-of-common-programming-errors\/"},"modified":"2014-04-13T22:40:18","modified_gmt":"2014-04-13T22:40:18","slug":"upload-video-file-using-httpclient-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/13\/upload-video-file-using-httpclient-collection-of-common-programming-errors\/","title":{"rendered":"Upload Video file using HttpClient-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m building Java client that will automatically upload file from Java server to Panda Instance that I installed on my EC2 cloud using their AMI. I&#8217;m trying to use Apache HTTP Components to upload to Panda Server (Panda Stream). It works fine with my browser client but for some reason I can&#8217;t upload from that library. Here is my code:<\/p>\n<pre><code>String videoUploadUrl = \"http:\/\/[panda server ip]\/videos\/\" + getVideoID() + \"\/upload.xml\";\nFile file = new File(\"\/temp\/videofile.mp4\");\n\nDefaultHttpClient httpclient = new DefaultHttpClient();\nhttpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);\n\nHttpPost httppost = new HttpPost(videoUploadUrl);\n\nMultipartEntity mpEntity = new MultipartEntity();\n\nContentBody fBody = new FileBody(file);\n\nmpEntity.addPart(\"userfile\", fBody);\n\nhttppost.setEntity(mpEntity);\n\n\nSystem.out.println(\"executing request \" + httppost.getRequestLine());\nHttpResponse response2 = httpclient.execute(httppost); \/\/<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m building Java client that will automatically upload file from Java server to Panda Instance that I installed on my EC2 cloud using their AMI. I&#8217;m trying to use Apache HTTP Components to upload to Panda Server (Panda Stream). It works fine with my browser client but for some reason I can&#8217;t upload from that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6204","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6204","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6204"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6204\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}