Class: FlatironS3Uploader::FileUploader

Inherits:
Object
  • Object
show all
Defined in:
lib/flatiron_s3_uploader/file_uploader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ FileUploader

Returns a new instance of FileUploader.



7
8
9
# File 'lib/flatiron_s3_uploader/file_uploader.rb', line 7

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/flatiron_s3_uploader/file_uploader.rb', line 5

def client
  @client
end

Instance Method Details

#upload(bucket, image, mime_type, directory = nil) ⇒ Object



11
12
13
14
15
# File 'lib/flatiron_s3_uploader/file_uploader.rb', line 11

def upload(bucket, image, mime_type, directory = nil)
  key = create_key(image, directory)
  client.put_object(bucket: bucket, key: key, acl: 'public-read', body: image, content_type: mime_type)
  "https://#{bucket}.s3.amazonaws.com/#{key}"
end