You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
773 B

# frozen_string_literal: true
require 'aws-sdk'
class MiniS3put
def initialize(key: nil, instream: $stdin)
@bucket = ENV.fetch('CPI_FEED_AWS_BUCKET')
@key = key || ENV.fetch('CPI_FEED_AWS_KEY')
@instream = instream
end
attr_reader :bucket, :key, :instream
private :bucket, :key, :instream
def put
Aws::S3::Resource.new.bucket(bucket).object(key).put(
body: instream.read
).on_success(&method(:on_put_success))
end
private def on_put_success(response)
puts response.data
Aws::S3::Client.new.put_object_acl(
bucket: bucket, key: key, acl: 'public-read'
).on_success do |acl_response|
puts acl_response.data
end
end
end
if $PROGRAM_NAME == __FILE__
MiniS3put.new(key: ARGV.first).put
exit 0
end