Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
AdrianQuartx
Posts: 105
Registered: ‎09-06-2013
My Device: Z10
Accepted Solution

[Email] Saving attachments to base64 encoded for use in EML

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

Please use plain text.
BlackBerry Development Advisor (Retired)
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: [Email] Saving attachments to base64 encoded for use in EML

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.
--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Please use plain text.