这段时间要忙迁移公司的业务到AWS,上,先简单的写一些,具体的有时间再补充了....
首先需要下载S3的相关的perl的pm:
http://developer.amazonwebservices.com/connect/entry.jspa?externalID=133&categoryID=47
#!/usr/bin/perl
# Simply connects to my S3 account, creates a new bucket
# and uploads a file called logo.jpg (passed thru STDIN) with
# public-read acl set
use strict;
use warnings;
print "you must specil file name for KEY\n" if @ARGV<1;
use S3;
use S3::AWSAuthConnection;
use S3::QueryStringAuthGenerator;
my $AWS_ACCESS_KEY_ID = '1DQ5TN5665Z7TVDNN682';
my $AWS_SECRET_ACCESS_KEY = 'CZpPQc55S2zF8JXwfME4JUOhpB9h4pQgTiGBF3sE';
my $BUCKET_NAME = 'squidwm' ;
my $KEY=$ARGV[0];
#my @file_name_for_key=split/\//,"$ARGV[0]";
#my $KEY = pop @file_name_for_key;
#print $KEY;
my %headers = (
'x-amz-acl' => 'public-read','Cache-Control'=>'24342',
);
my $conn =
S3::AWSAuthConnection->new($AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCESS_KEY);
my $generator =
S3::QueryStringAuthGenerator->new($AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCESS_KEY);
print $conn->create_bucket($BUCKET_NAME)->message, "\n";
my $data ;
FILE: while(1) {
my $n = sysread(STDIN, $data, 1024 * 1024, length($data));
if ($n < 0) {
print STDERR "Error reading input: $!\n";
exit 1;
|
使用时: ./put_obj_s3 test.jpg
阅读(1689) | 评论(0) | 转发(0) |