Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Downloading Gmail attachments - Corrupted saved file

by localshop (Sexton)
on May 13, 2013 at 23:15 UTC ( #1033376=note: print w/replies, xml ) Need Help??

in reply to Downloading Gmail attachments - Corrupted saved file

A couple of points. If you are running on Windoze you may want to write the files in binary mode (see binmode). Also it looks to me as though you are trying to append the files instead of writing to them. Here's my code that works ok:
foreach my $at ( @attachments ) { if ( $at->{content_type} =~ /pdf/i ) { open(my $fh, '>', $at->{filename} ) || die ( $!); binmode $fh; print $fh $at->{payload}; $fh->close(); } }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1033376]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2018-07-16 04:59 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (332 votes). Check out past polls.