I am using the google-http-client for java to handle http connections on Android.
Everything is HunkyDori with it thus far until trying to send a multipart/form-data
Content.
I am a little bit stuck, I am thinking about adapting the MultipartContent
class to create my own version of MultipartFormContent
.
I need a version of MultipartEntity
which would effectivly work like:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
FileBody bin = new FileBody(new File(fileName));
StringBody comment = new StringBody("Filename: " + fileName);
MultipartEntity reqEntity = new MultipartEntity();
reqEntity.addPart("bin", bin);
reqEntity.addPart("comment", comment);
httppost.setEntity(reqEntity);
HttpResponse response = httpclient.execute(httppost);
HttpEntity resEntity = response.getEntity();
From reading around, the only difference between, multipart/relative
and multipart/form
is that one adds the name when printing out?
Anyone got any ideas about adapting the MultipartContent
class to support the 'name' field.
Regards.
Ok, I created the following class based off of the MultipartContent class:
This is working for me, I am using against Cloudinary.