Archived Forum Post

Index of archived forum posts

Question:

"mime.LoadMimeFile" worked but "mime.LoadMime" failed

Dec 08 '15 at 12:11

I am using the latest library “chilkat-9.5.0-armv6-linux.tar.gz” 30 days trial version. I collected a multipart response and dumped into the file and then was able to parse it using "mime.LoadMimeFile()”. But if I store the multipart response into a local memory buffer and try to parse it using "mime.LoadMime()", it fails. The multipart response in first part contains audio data in WAV format and in second part it has a text/plain. It looks like that "mime.LoadMime" is not able to load all available data into mime. Is there a way to parse multipart data using chilkat library? My multipart data is: --myBoundary Content-Type: audio/x-wav

RIFFÔ WAVEfmt    €> }  data® ÿÿÿÿ ÿÿÿÿ ÿÿÿÿ   þÿ ÿÿ ÿÿ    
--myBoundary Content-Type: text/plain; charset=utf-8 { my text is here. }

Appreciates your help.


Accepted Answer

I suspect this is the problem: The MIME contains binary (non-text) data in 8bit encoding. In other words, it is binary MIME that is not using base64 content encoding for the WAV data.

LoadMime is expecting a string, and a string must be something where the bytes represent characters. Therefore, LoadMime should only be used when the MIME does not contain raw non-character byte data.

If the MIME is binary, then the correct method to call is LoadMimeBytes. First load the MIME bytes into a CkByteData object (or have the CkByteData "borrow" the bytes to avoid copying, if copying is more than a negligible task), and then pass the CkByteData object to LoadMimeBytes.