Method: Dev::Aws::S3#put
- Defined in:
- lib/firespring_dev_commands/aws/s3.rb
#put(bucket:, key:, filename:, acl: 'private') ⇒ Object
Puts the local filename into the given bucket named as the given key Optionally specify an acl. defaults to ‘private’ Returns the URL of the uploaded file
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/firespring_dev_commands/aws/s3.rb', line 22 def put(bucket:, key:, filename:, acl: 'private') begin File.open(filename, 'rb') do |file| client.put_object(bucket:, key:, body: file, acl:) end rescue => e raise "s3 file upload failed: #{e.message}" end url = "https://#{bucket}.s3.#{Dev::Aws::Credentials.new.logged_in_region}.amazonaws.com/#{key}" LOG.info "Uploaded #{url}" url end |