Hi Monks,
I have base64 pdf data that stored in database. The code that I am trying to write is
to decode the base64 data from database write it into file with .pdf extension upload that file
on amazon S3 and generate URL for pdf file. Everything seems fine but while hitting generated URL
on browser I am getting an error "Failed to load PDF document".I am using Amazon::S3 and Muck::FS::S3::QueryStringAuthGenerator
cpan modules for amazon upload and MIME::Base64 for decoding Base64 pdf data.
below is the code snippet:

my $s3 = Amazon::S3->new ( { aws_access_key_id => $aws_Access_key_id, aws_secret_access_key => $aws_secret_access_key } ); my $test_bucket = $s3->bucket("testbucket"); my $uploadFile_keyname = "r3u3298982938"; my $add_file_test = $test_bucket->add_key_filename("$uploadF +ile_keyname","$cUpload_file",{content_type=>'application/pdf'}) or die "Couldn't copy file to bucket" .$s3->errstr ."\n"; my $response = $test_bucket->list; for my $key(@{ $response->{keys}}) { if($key->{key} eq "$uploadFile_keyname") { my $urlenerator = Muck::FS::S3::QueryStringAuthGenerat +or->new($aws_Access_key_id,$aws_secret_access_key); $urlenerator->expires_in(36000000); $url = $urlenerator->get('testbucket',"$uploadFile_key +name"); } } return $url;

In reply to Upload to AWS S3 bucket by sachinhere

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.