10-23-2013 03:14 AM
I am trying to save emails to eml files. For the attachments, how do I get the base64 encoding of the binary files?
I suppose I could do a Qdatastream, but wouldnt Base64 encoding requires reading in the whole file at once?
The attachments can be from a few kb (small issue) to 50+ mbs, can anyone point me in the right direction
Solved! Go to Solution.
10-24-2013 03:35 AM
I think Base64 encoding works on groups of 3 bytes at a time so you would not need to read the whole attachment in one go. QByteArray has a toBase64() method you could use for this.
See http://www.ietf.org/rfc/rfc2045.txt where it says:
The encoding process represents 24-bit groups of input bits as output strings of 4 encoded characters. Proceeding from left to right, a 24-bit input group is formed by concatenating 3 8bit input groups. These 24 bits are then treated as 4 concatenated 6-bit groups, each of which is translated into a single digit in the base64 alphabet.