In my web application, client sends XML request.This XML request contains a File (mostly Image and audio) data which is Base64 encoded.
What my application does is parse the XML get the encoded file content and after decoding the file content back to binary,
file is saved on local file system.
If i send POST request from a JSP page it is working fine, but its not working if I send a custom POST request from java class.
Server does receive file but file is corrupted.However simple text file is not corrupted in any of the above clients.
Figured out the problem, In my custom client I am setting Content-Type to "application/x-www-form-urlencoded "
but request parameters are not URL Encoded automatically like it is done by browser.
URLEncoding the request parameters worked.
The above solution was not preferable because it requires two encodings first Binary to base64 and second URLEncoding the entire request.
So set Content-Type to "multipart/form-data", where only binary to Base64 encoding is required.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Base64 encoded file as POST request not working correctly.