Module: UtilityBelt::AmazonUploadShortcut

Included in:
Object
Defined in:
lib/utility_belt/amazon_upload_shortcut.rb

Instance Method Summary collapse

Instance Method Details

#aws_upload(bucket, filename) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/utility_belt/amazon_upload_shortcut.rb', line 6

def aws_upload(bucket,filename)
  AWS::S3::Base.establish_connection!(:access_key_id => ENV['AMAZON_ACCESS_KEY_ID'], 
                                      :secret_access_key => ENV['AMAZON_SECRET_ACCESS_KEY'])
  AWS::S3::S3Object.store(filename, open(filename), bucket, :access => :public_read)
  url = "http://s3.amazonaws.com/#{bucket}/#{filename}".gsub(/ /, "%20")
  Clipboard.write(url) if Clipboard.available?
  url
end