Sha256: e960c527e11c5719bf88b4a013b3452029a219a7c0e07212896671ee0eb810a5
Contents?: true
Size: 610 Bytes
Versions: 2
Compression:
Stored size: 610 Bytes
Contents
# frozen_string_literal: true module FlatironS3Uploader class FileUploader attr_reader :client def initialize(client) @client = client end 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 private def create_key(image, directory) filename = File.basename(image).sub('-resized', '') directory ? "#{directory}/#{filename}" : filename end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
flatiron-s3-uploader-0.1.2 | lib/flatiron_s3_uploader/file_uploader.rb |
flatiron-s3-uploader-0.1.1 | lib/flatiron_s3_uploader/file_uploader.rb |