I have a Base64 binary string that is part of an XML document that is sent to us by a 3rd party supplier, I would like to be able to save it back to its original file format (jpg).
Using the accepted answer from this question "saving a base64 string to disk as a binary using php" I can save the string to a jpg with little effort, so I know the string is in good form and is a JPG file.
But how do I do this in Delphi 2007?
Looking on the net I found a tutorial on how to convert the Base64 into a TByteDynArray, and save that, but it doesn't work right. I have also played about with Indy's IdDecoderMIME, but with with no success.
Does any one know how to do this, or where I should be looking?
The Internet Direct (Indy) library contains classes in IdCoderMIME.pas which support Base64 encoding and are easy to use: TIdEncoderMIME and TIdDecoderMIME.
OmniXMLUtils.pas from the OmniXML project contains following functions:
The Base64Decode(string, TStream) should do the trick. For the TStream parameter you can pass it TFileStream like this: