Method: Gluttonberg::Library::Storage::S3::ClassMethods#upload_file_to

Defined in:
lib/gluttonberg/library/storage/s3.rb

#upload_file_to(asset, bucket_key, mime_type, local_file) ⇒ Object



68
69
70
71
72
73
74
75
76
77
# File 'lib/gluttonberg/library/storage/s3.rb', line 68

def upload_file_to(asset, bucket_key, mime_type, local_file)
  options = {
    :expires => (Time.now+1.years).rfc2822,
    :acl => :public_read
  }
  mime_type = asset.mime_type if mime_type.blank?
  options[:content_type] = mime_type unless mime_type.blank?
  response = bucket_key.write(File.open(File.join((Rails.env == 'test' ? Engine.root : Rails.root),local_file)), options)
  puts "Copied"
end