Do you have any idea on how to extract attachment from the incoming message? I have a PDF attached to the message. This is what I see in the console:
['contentType':'application/pdf; name="TransakciaMK.pdf"', 'filename':'TransakciaMK.pdf', 'disposition':'attachment', 'contentBytes':'[B@d2d9e15']
I wanted to use the code used for uploading files
org.apache.commons.fileupload.FileItem
to a service, which saves the file.
- Is this a correct way of doing it?
- If yes, how can I render the attachment into a FileItem?
Added:
OK. I must be doing something wrong. I extract the byte[] using bodyPartList[2].contentBytes.getBytes(). Into variable called contentFileByte.
Then:
ByteArrayInputStream fileStream = new ByteArrayInputStream(contentFileByte)
try { docRr.putStream(fileStream) } finally { fileStream.close() }
A file is created, but it contains only:
[B@d2d9e15
There must be an error somewhere on the way of converting the byte array to a file stream.