use of com.bixly.pastevid.util.view.ProgressMultiPartEntity in project screenbird by adamhub.
the class FileUtil method postData.
public static String[] postData(String data, final JProgressBar pbUpload, String anonymous_token, String csrf_token, String user_id, ProgressBarUploadProgressListener listener, String upload_url) throws IOException {
HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
HttpPost httppost = new HttpPost(upload_url);
//File file = new File(fileLocation);
//MultipartEntity mpEntity = new MultipartEntity();
ProgressMultiPartEntity mpEntity = new ProgressMultiPartEntity(listener);
//ContentBody cbFile = new FileBody(file, "video/quicktime");
//mpEntity.addPart("videoupload", cbFile);
//ContentBody cbToken = new StringBody(title);
//mpEntity.addPart("csrfmiddlewaretoken", cbToken);
ContentBody cbUser_id = new StringBody(user_id);
mpEntity.addPart("user_id", cbUser_id);
ContentBody cbAnonym_id = new StringBody(MediaUtil.getMacAddress());
mpEntity.addPart("anonym_id", cbAnonym_id);
//ContentBody cbTitle = new StringBody(title);
//mpEntity.addPart("title", cbTitle);
// ContentBody cbSlug = new StringBody(slug);
// mpEntity.addPart("slug", cbSlug);
// ContentBody cbPublic = new StringBody(is_public ? "1" : "0");
// mpEntity.addPart("is_public", cbPublic);
// ContentBody cbDescription = new StringBody(description);
// mpEntity.addPart("description", cbDescription);
// ContentBody cbChecksum = new StringBody(checksum);
// mpEntity.addPart("checksum", cbChecksum);
// ContentBody cbType = new StringBody(video_type);
// mpEntity.addPart("video_type", cbType);
httppost.setEntity(mpEntity);
System.out.println("===================================================");
System.out.println("executing request " + httppost.getRequestLine());
System.out.println("===================================================");
HttpResponse response = httpclient.execute(httppost);
HttpEntity resEntity = response.getEntity();
String[] result = new String[2];
String status = response.getStatusLine().toString();
result[0] = (status.indexOf("200") >= 0) ? "200" : status;
System.out.println("===================================================");
System.out.println("status from request " + result[0]);
System.out.println("===================================================");
if (resEntity != null) {
result[1] = EntityUtils.toString(resEntity);
EntityUtils.consume(resEntity);
}
httpclient.getConnectionManager().shutdown();
return result;
}
Aggregations