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.

33 lines
707 B

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
def put
Aws::S3::Resource.new.bucket(bucket).object(key).put(
body: instream.read
).on_success(&method(:on_put_success))
0
end
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
private
attr_reader :bucket, :key, :instream
end
exit(MiniS3put.new(key: ARGV.first).put) if $PROGRAM_NAME == __FILE__