You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by "joh sar....." <eh...@gmail.com> on 2011/06/07 09:06:49 UTC

Problem in MIME: change Content-Transfer-Encoding binary to base64 !

Hi !

I'm writing because I didn't find how i can change the type of content
Transfer Encoding in a multipart message that i send with a HTTP Post
request .

For this, i use the library httpmime-4.1.1.jar from:
http://hc.apache.org/htppcomponents-client/httpmime/index.html.

In my project, i try to send a base64 JPG but for the moment i have
just send a binary JPEG and my hope is so with a base64.

Does anyone know how change this content transfer type or help me ? it
will be very helpful.

I have tried with an instance of FileBody but it was a flop... and i
have read the code but i found nothing.

Thanks
johan S.

PS: If I find before, i will write you and sorry for my english !

the piece of code :


               File photo = new File(Environment.getExternalStorageDirectory()
                               + File.separator + "DCIM", "outs0.jpg");
               FileBody fb = new FileBody(photo, "image/jpeg");

               HttpClient httpClient = new DefaultHttpClient();
               HttpPost httpPost = new HttpPost(adr);

               MultipartEntity multipartContent = new MultipartEntity();

               multipartContent.addPart("infosString", testString);
               multipartContent.addPart("photo1",fb);
               try {
                       httpPost.setEntity(multipartContent);

                       HttpResponse response = httpClient.execute(httpPost);
                       HttpEntity httpEntity = response.getEntity();
                       line = EntityUtils.toString(httpEntity);
               }catch{...}

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Problem in MIME: change Content-Transfer-Encoding binary to base64 !

Posted by "joh sar....." <eh...@gmail.com>.
Thanks you for this help !!

But now i have a problem with mime4j.
I try to construct a mime with a jpeg on Android. And I have found one
method that doesn't work with this plateform.

How can i put my jpg in the Mime ? I don't find the method which give me this !
Is a StorageProvider and a Storage before a binaryBody  ? I don't
understand with which methods i can obtain my image to send the MIME !

Does anyone help me or give me some clues ?

Thanks
Johan S

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Problem in MIME: change Content-Transfer-Encoding binary to base64 !

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2011-06-07 at 09:06 +0200, joh sar..... wrote:
> Hi !
> 
> I'm writing because I didn't find how i can change the type of content
> Transfer Encoding in a multipart message that i send with a HTTP Post
> request .
> 
> For this, i use the library httpmime-4.1.1.jar from:
> http://hc.apache.org/htppcomponents-client/httpmime/index.html.
> 
> In my project, i try to send a base64 JPG but for the moment i have
> just send a binary JPEG and my hope is so with a base64.
> 
> Does anyone know how change this content transfer type or help me ? it
> will be very helpful.
> 
> I have tried with an instance of FileBody but it was a flop... and i
> have read the code but i found nothing.
> 
> Thanks
> johan S.
> 
> PS: If I find before, i will write you and sorry for my english !
> 

HttpMime supports the binary (identity) transfer encoding only. If you
need to support more complex transfer encodings there is no way around
having to build custom ContentBody implementations. You might want to do
that using Apache Mime4j that supports all standard MIME codecs such as
BASE64 and Quoted-Printable out of the box.

Oleg


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org