加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

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

发布时间:2020-12-15 23:25:31 所属栏目:大数据 来源:网络整理
导读:我正在尝试使用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,$valu
我正在尝试使用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',}
);

根据需要调整内容类型.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读