Module: Paperclip::S3::ClassMethods

Defined in:
lib/paperclip-s3.rb

Instance Method Summary collapse

Instance Method Details

#has_attached_file(name, options = {}) ⇒ Object

Extends the paperclips has_attached_file method It will use S3 Storage. The credentials will be read from the environment



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/paperclip-s3.rb', line 19

def has_attached_file(name, options = {})
  s3_protocol = !!ENV["S3_PROTOCOL"] ? ENV["S3_PROTOCOL"] : "http"
  options[:storage] = :s3
  options[:path]    ||= "/:class-:attachment/:id/:style-:basename.:extension"
  options[:bucket]  ||= ENV["S3_BUCKET"]
  options[:s3_protocol] ||= s3_protocol
  options[:s3_credentials] ||= {
                                  :access_key_id => ENV['S3_KEY'],
                                  :secret_access_key => ENV['S3_SECRET']
                              }
  super(name, options)
end