For a long time i was thinking that Amazon`s Simple Storage Service (S3) is very complicated thing. But, it was before i tried it. Couple days ago, i got account to S3 and started exploring API`s and architecture. Now i see how stupid i was
It`s really easy to handle all operations with files and buckets. Pricing also comfortable.
Welcome to cloud computing!
I started using it with Ruby. Regular gem and docs can be found at http://amazon.rubyforge.org/
So, the first useful tool i decided to created – simple uploader of local files to amazons server.
First, we need to create bucket and make it public:
Bucket.create('NAME_HERE',:access => :public_read)
Here`s the client ruby script:
#!/usr/bin/ruby require 'rubygems' require 'aws/s3' include AWS::S3 $s3_bucket = "BUCKET_NAME" $s3_key = "API_KEY" $s3_secret = "API_SECRET" def s3_store(localfile) if File.exists?(localfile) && File.readable?(localfile) puts "Uploading file [#{localfile}]. Size: #{File.size(localfile)} bytes." name = File.basename(localfile) Base.establish_connection!(:access_key_id => $s3_key, :secret_access_key => $s3_secret) S3Object.store(name, open(localfile), $s3_bucket, :access => :public_read) puts "Download link: http://s3.amazonaws.com/#{$s3_bucket}/#{name}" else puts "File not exists or not accessible. Please check file and try again!" end end path = ARGV[0] if !path "Please specify the file to upload." else s3_store(path) end
Download script: http://files.sosedoff.com/036cfedd/
BTW, I found cool firefox add-on to manage S3 objects/files. It`s pretty easy.
Link to extension – http://www.s3fox.net
Screenshot:


