如何上传到Amazon S3图像使用Perl? [英] How To Upload Images to Amazon S3 Using Perl?
问题描述
我要上传的文件使用Perl来S3。
I'm trying to upload files to S3 using Perl.
据该模块:
http://metacpan.org/pod/Amazon::S3 ::斗
...以下code会上传文本文件:
...the following code will upload text files:
# 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?
However, how do you upload images (GIF, JPEG, PNG) to S3?
谢谢
琳达
推荐答案
这code的不会的上传文件 - 它只是设置的键testing.txt相关联的值以T。如果你想上传一个文件,你可以使用<一个href="http://search.cpan.org/~tima/Amazon-S3/lib/Amazon/S3/Bucket.pm#add_key_filename">add_key_filename方法:
That code won't upload the file - it's simply setting the value associated with the key "testing.txt" to "T". If you want to upload a file you could use the add_key_filename method:
的方法的工作方式类似add_key除的值被假定为一 文件名中的本地文件系统上。该文件将被流而 然后加载到内存在一大块。
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',
}
);
调整为所需的内容类型。
Adjust the content type as required.
这篇关于如何上传到Amazon S3图像使用Perl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!