Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mime::Base64 Problem

Status
Not open for further replies.

LucL

Programmer
Jan 23, 2006
117
US
Hi Guys,

I'm having a problem converting large binary e-mail attachments from base64 to Perl string format.

I'm using MIME::Base64. The attachment is formatted properly and perfectly. All rows have the proper amount of characters and padding if necessary. The e-mails were sent from outlook, hotmail, yahoo.

Here is the problem. With small binary attachments, < 1 meg there are no problems.

With larger attachments > 1 meg, I always get a "Premature end of base64 data" and while the conversion completes, the converted file is a few hundred bytes smaller than the original file and always corrupted.

I've searched all over and can't find whether or not this is a bug with MIME::Base64. I'm using the latest version. The MIME::Base64 readme says this is just a warning, but the files are corrupted so there must be another problem.

Once again, this only happens with binary (video) files over 1 meg, smaller ones seems to work fine.

If necessary, I can upload the e-mail source along with attachment but they're about 2 megs.

Thanks,
Luc L.
 
Taken from the MIME::Base64 docs.

"The number of characters to decode is not a multiple of 4. Legal base64 data should be padded with one or two "=" characters to make its length a multiple of 4. The decoded result will be the same whether the padding is present or not."

 
Thanks UnixJunky but unfortunately the data length is a multiple of 4 and no padding is required.
 
could be the script is timing out? How long deos it seem to take to convert a file around 1 meg?
 
It's nearly instant. I didn't time it but as soon as I run the script the error pops up <1 second later. I'm running from root just to be on the safe side.

The conversion completes but the file is corrupted.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top