Hello,
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.
/MultipartEntityBuilder.create()
.setBoundary(boundary)
.setCharset(Charset.forName("UTF-8"))
.setMode(HttpMultipartMode.STRICT);/
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="??
copy.jpg"**
**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,
Dhruva