hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dhruvakumar P G <dhruvakumar....@oracle.com>
Subject Facing a problem while uploading any file whose name contains multibyte characters
Date Tue, 03 Dec 2013 16:07:44 GMT

I'm upgrading HttpMIME library to 4.3.1 in a proxy server and this proxy 
module is supposed to upload any kind of files to other backend server.
I'm using org.apache.http.entity.mime.MultipartEntityBuilder to 
construct multipart entity.

When I upload an image file named copy.jpg(ascii characters file name), 
the new code is able to upload the image and the request headers are 
sent as below
*Content-Disposition: form-data; name="fileToUpload"; filename="copy.jpg"**
**Content-type: image/jpeg; charset=UTF-8**
**Content-Transfer-Encoding: binary*

And if I try to download the same image, response headers from the 
backend server are:
*Content-type: image/jpeg; charset=UTF-8**
**Content-disposition: attachment; filename="=?utf-8?encodedfilename?='*

But when I upload an image file named *ウェ copy.jpg*(multibyte 
characters filename), the new code is uploading the image but the 
request headers are sent as below
*Content-Disposition: form-data; name="fileToUpload"; filename="?? 
**Content-type: image/jpeg; charset=UTF-8**
**Content-Transfer-Encoding: binary*

Instead of sending non-ascii multibyte characters in the file name, it's 
sending '??'. And from the server we get empty characters for those 
positions in the file name.
What could be the issue here ?  Do I have to encode the file name 
explicitly ?

There seems to be no APIs available in MultipartEntityBuilder to address 
this issue.
How to send and receive multibyte data without losing anything If 
filename or body  contains multibyte characters ?

Thanks and Regards,

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message