Sha256: 93e9f1c23a5a4d1f2da44795bd00b200c42712c4186a6c6c06a28ab9619bd866

Contents?: true

Size: 1018 Bytes

Versions: 13

Compression:

Stored size: 1018 Bytes

Contents

# S3 (http://amazon.rubyforge.org/)
%w{aws/s3 cgi platform}.each {|lib| require lib}

module UtilityBelt
  module AmazonUploadShortcut
    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
  end
end
    
class Object
  include UtilityBelt::AmazonUploadShortcut
end if Object.const_defined? :IRB

# a quick note: the "google" command uses CGI.escape, but the URLs produced by CGI.escape
# don't seem to succeed here, in practice. this may differ by OS and/or browser. Let me
# know if you see something weird -- the Utility Belt mailing list is here:
#
# http://rubyforge.org/mailman/listinfo/utilitybelt-tinkering

Version data entries

13 entries across 13 versions & 6 rubygems

Version Path
FreedomCoder-utility_belt-1.1.1.2 lib/utility_belt/amazon_upload_shortcut.rb
FreedomCoder-utility_belt-1.1.1 lib/utility_belt/amazon_upload_shortcut.rb
akitaonrails-utility_belt-1.0.10 lib/utility_belt/amazon_upload_shortcut.rb
akitaonrails-utility_belt-1.0.11 lib/utility_belt/amazon_upload_shortcut.rb
akitaonrails-utility_belt-1.0.12 lib/utility_belt/amazon_upload_shortcut.rb
mguterl-utility_belt-1.0.7 lib/utility_belt/amazon_upload_shortcut.rb
rwilcox-utility_belt-1.0.7 lib/utility_belt/amazon_upload_shortcut.rb
rwilcox-utility_belt-1.0.9 lib/utility_belt/amazon_upload_shortcut.rb
timocratic-utility_belt-1.0.7.1 lib/utility_belt/amazon_upload_shortcut.rb
timocratic-utility_belt-1.0.7.2 lib/utility_belt/amazon_upload_shortcut.rb
timocratic-utility_belt-1.0.7.3 lib/utility_belt/amazon_upload_shortcut.rb
akitaonrails-utility_belt-1.0.13 lib/utility_belt/amazon_upload_shortcut.rb
utility_belt-1.1.0 lib/utility_belt/amazon_upload_shortcut.rb