Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Need to print bucket and filename which is uploaded on S3 storage

by coolsaurabh (Acolyte)
on Aug 21, 2019 at 07:59 UTC ( #11104778=note: print w/replies, xml ) Need Help??


in reply to Re: Need to print bucket and filename which is uploaded on S3 storage
in thread Need to print bucket and filename which is uploaded on S3 storage

The output of this script is blank.
#!/opt/perl/bin/perl use Amazon::S3; my $file_name = "filename.txt"; my $bucketName = "forest-upload"; my $s3 = Amazon::S3->new({ aws_access_key_id => "XX", aws_secret_access_key => "XX", retry => 1 }); my $bucket = $s3->bucket($bucketName); $bucket->add_key_filename( $file_name, $file_name, { content_type => "text/plain", } ); my $result = $s3->buckets(); my @buckets; @buckets = @{ $result->{buckets} } if defined $result;
  • Comment on Re^2: Need to print bucket and filename which is uploaded on S3 storage
  • Download Code

Replies are listed 'Best First'.
Re^3: Need to print bucket and filename which is uploaded on S3 storage
by Corion (Pope) on Aug 21, 2019 at 08:00 UTC

    That means there was an error returned by Amazon.

    Have you checked the errors in $s3->err and $s3->errstr?

    Also, maybe you have not created any buckets yet?

      the script returned some HASH value when I am trying to print $s3 value.
      use Amazon::S3; my $file_name = "filename.txt"; my $bucketName = "forest-upload"; my $s3 = Amazon::S3->new({ aws_access_key_id => "XX", aws_secret_access_key => "XX", retry => 1 }); print $s3;
      Output is "Amazon::S3=HASH(0xafac08)"

        Yes.

        But you have no error checking here:

        my $result = $s3->buckets();

        If $result is not defined, which happens when there is an error, you ignore that.

        Instead of ignoring that, check the errors there. This is documented in Amazon::S3. Maybe the following helps:

        my $result = $s3->buckets(); if( ! $result ) { warn "There was an error when looking at the existing buckets:"; warn join " - ", $s3->err, $s3->errstr; die "Cannot continue."; }; ...
Re^3: Need to print bucket and filename which is uploaded on S3 storage
by Anonymous Monk on Aug 21, 2019 at 11:51 UTC
    the script has no calls to "print" or "say", so why would you expect non-blank output?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11104778]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2020-12-01 22:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (23 votes). Check out past polls.

    Notices?