sachinhere has asked for the wisdom of the Perl Monks concerning the following question:
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Upload to AWS S3 bucket
by hippo (Archbishop) on Jan 17, 2018 at 09:08 UTC | |
by sachinhere (Novice) on Jan 17, 2018 at 10:05 UTC |