我正在尝试使用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',} );
根据需要调整内容类型.