hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: AW: MultipartEntityBuilder with special char in filename
Date Wed, 22 Apr 2015 10:45:24 GMT
On Tue, 2015-04-21 at 16:18 +0000, Olaf Scheidt wrote:
> Hi Community
> How can I send a thumbail with percent char in Filename e.g. a%02.jpg. Percent is removed
at the destination. a%02.jpg=>a02.jpg
> File filename=new File("/tmp/a%02.jpg");
> HttpPost post = new HttpPost(url);
> MultipartEntityBuilder mpe = MultipartEntityBuilder.create();
> mpe.setCharset(Charset.forName("UTF-8"));
> mpe.addBinaryBody("fileData",filename,ContentType.create("image/jpeg"),filename.getName());
> post.setEntity(mpe.build())
> Regards,
> Oliver


Percent sign should be legal for file names. You can try encoding the
file name with q-printable or base64 codecs but there is no guarantee
the server would be able to decode it correctly.

For more complex scenarios involving MIME consider using Apache Mime4J
instead of HttpMime.



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

View raw message