这个 perl 将一个 jpeg 文件上传到 S3,将其放在减少冗余存储中,将其公开,并设置其 mime 类型,以便它在 Web 浏览器中正确显示。请查看上传结果:https ://s3.amazonaws.com/AppaApps/z/p.jpg
use warnings FATAL => qw(all);
use strict;
use Data::Dump qw(dump);
use Amazon::S3;
#----------------------------------------------------------------------
# Constants
#----------------------------------------------------------------------
my $s3 = Amazon::S3->new
({aws_access_key_id => "...",
aws_secret_access_key => "...",
retry => 1
}
);
my $b = $s3->bucket("AppaApps"); # Our bucket
my $f = "z/p.jpg"; # A specific file (key) on S3
my $F = "p.jpg"; # Local file to upload
#----------------------------------------------------------------------
# Upload a file
#----------------------------------------------------------------------
$b->add_key_filename($f, "p.jpg",
{"x-amz-storage-class"=>"REDUCED_REDUNDANCY", 'x-amz-meta-version'=>'12.11.22', acl_short=>'public-read',
"Content-Type"=>"image/jpeg",
});
print dump($b->errstr), "\n" if $b->errstr;