sugarboy has asked for the wisdom of the Perl Monks concerning the following question:

Hai , I am supposed to upload a file via a .Net webservice, and the data will be accepted in base64Binary , how do i do that, if i just read the string into a variable and set the type to base64 will resolve this, please resolve Thanks in Advance, Sugarboy
  • Comment on How to upload a data file in base64Binary format?

Replies are listed 'Best First'.
Re: How to upload a data file in base64Binary format?
by zentara (Cardinal) on Jun 26, 2007 at 16:01 UTC
    base64Binary seems like a contradictory term to me. Maybe they want a base64encoded binary?
    #!/usr/bin/perl use strict; use MIME::Base64 qw( encode_base64 ); # provide 2 filenames as args on the commandline # first the binary, second the encoded file #encode open INFILE, '<', $ARGV[0]; binmode INFILE; open OUTFILE, '>', $ARGV[1]; my $buf; while ( read( INFILE, $buf, 4096 ) ) { print OUTFILE encode_base64($buf); } close OUTFILE; close INFILE; ################################################### #decode_base64.pl: #!/usr/bin/perl use strict; use MIME::Base64 qw( decode_base64 ); open INFILE, '<', $ARGV[0]; open OUTFILE, '>', $ARGV[1]; binmode OUTFILE; my $buf; while ( $buf = <INFILE> ) { print OUTFILE decode_base64($buf); } close OUTFILE; close INFILE;

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum