I'm receiving a SOAPMessage over a java servlet with an attachmentpart containing a multipart mime. Doing this:
InputStream inputStream = request.getInputStream();
byte[] data = IOUtils.toByteArray(inputStream);
File file = new File("/usr/local/user/message.txt");
FileOutputStream fos = new FileOutputStream(file);
fos.write(data);
fos.close();
Gives me corrupted data for the binary code in the multipart mime. Anyone knows why this is happening? I copied the binary data to a file and changed the file extension to the appropriate image extension but I'm getting a corrupted image. Comparing hexadecimal data of message.txt and a .snoop file shows that there are slight differences in the hexadecimal data causing the distortion. There were no changes in the ASCII data. Thanks.
There is distortion, as in you can see the picture looks correct at the start, but it starts looking weird after a while because the hexadecimal values are wrong. For example: 06 04 04 04 04 04 06 04 04 06 0a from the client becomes 06 04 04 04 04 04 06 04 04 06 0D after I do the above.