Class: FlatironS3Uploader::FileUploader
- Inherits:
-
Object
- Object
- FlatironS3Uploader::FileUploader
- Defined in:
- lib/flatiron_s3_uploader/file_uploader.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(client) ⇒ FileUploader
constructor
A new instance of FileUploader.
- #upload(bucket, image, mime_type, directory = nil) ⇒ Object
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
#client ⇒ Object (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 |