|Pathologically Eclectic Rubbish Lister|
decode_base64 MIME PDF Failingby kiteskitesyay (Initiate)
|on Jun 26, 2011 at 23:34 UTC||Need Help??|
kiteskitesyay has asked for the
wisdom of the Perl Monks concerning the following question:
I am trying to pull a PDF file out of a gmail message via IMAP, and write it to file on local disk.
I can successfully connect to gmail, search (and find) the message in question, grab it in its entirety as a string, and navigate to the attachment. Now I need to decode it, and write it to file. Here is that portion of my code:
This writes a file, and it opens as a PDF. However, it's 3 blank pages.
Even more frustrating, if I just print '$blob' as a txt file, and copy the contents, I can use an online base64 decoder like this one: http://www.opinionatedgeek.com/dotnet/tools/base64decode/
And the resultant file opens as a PDF and has my content.
Any reason that decode_base64() is not returning a readable file? The file it does write is very close in size, (402KB vs 398KB for a good file), and kdiff reports that they're ascii-identical, but not binary-identical. All the readable parts match. I'm on Windows, using Perl 5.10.1 and MIME::Base64 version 3.13.