如何使用Perl将图像上传到Amazon S3?

我正在尝试使用Perl将文件上传到S3.

根据这个模块:

http://metacpan.org/pod/Amazon::S3::Bucket

…以下代码上传文本文件

# create resource with Meta data (attributes)
my $keyname = 'testing.txt';
my $value   = 'T';
$bucket->add_key(
   $keyname,$value,{   content_type        => 'text/plain','x-amz-Meta-colour' => 'orange',}
);

但是,如何将图像(GIF,JPEG,PNG)上传到S3?

谢谢,

琳达

解决方法

代码不会上传文件 – 它只是将与“testing.txt”键相关联的值设置为“T”.如果要上传文件,可以使用 add_key_filename方法

The method works like add_key except the value is assumed to be a
filename on the local file system. The file will be streamed rather
then loaded into memory in one big chunk.

就像是:

$bucket->add_key_filename(
    'image-key.jpg','local-filename.jpg',{
        content_type => 'image/jpeg',}
);

根据需要调整内容类型.

相关文章

1. 如何去重 #!/usr/bin/perl use strict; my %hash; while(...
最近写了一个perl脚本,实现的功能是将表格中其中两列的数据...
表的数据字典格式如下:如果手动写MySQL建表语句,确认麻烦,...
巡检类工作经常会出具日报,最近在原有日报的基础上又新增了...
在实际生产环境中,常常需要从后台日志中截取报文,报文的形...
最近写的一个perl程序,通过关键词匹配统计其出现的频率,让...