#!/usr/bin/perl use strict; use warnings; use File::Basename; use Net::Amazon::S3; # you need an account with Amazon s3 in order to get a key and a secret key my $aws_access_key_id = 'replace with your key'; my $aws_secret_access_key = 'replace with your secret key'; # each account can only have 100 buckets # each bucket can hold an 'infinite' number of files my $bucketname = 'your_bucket_name'; # get the file that is to be uploaded from the command line my $full_path = $ARGV[0]; my($filename, $path) = fileparse($full_path); die "can not find $full_path\n" if ( ! -f $full_path ); # try to connect with your keys to Amazon my $s3 = Net::Amazon::S3->new( { aws_access_key_id => $aws_access_key_id, aws_secret_access_key => $aws_secret_access_key, }) or die "could not connect to amazon.com"; print "uploading $filename to amazon\n"; # this should not make any network call my $bucket = $s3->bucket($bucketname); # try uploading the file $bucket->add_key_filename($filename, $full_path) or die "failed uploading $full_path\n"; print "success\n";