cpi-feed/mini_s3put.rb
2015-10-04 18:41:08 -04:00

18 lines
358 B
Ruby

require 'aws-sdk'
def main
bucket = ENV.fetch('CPI_FEED_AWS_BUCKET')
key = ARGV.first || ENV.fetch('CPI_FEED_AWS_KEY')
puts Aws::S3::Resource.new.bucket(bucket).object(key).put(
body: $stdin.read
)
puts Aws::S3::Client.new.put_object_acl(
bucket: bucket, key: key, acl: 'public-read'
)
0
end
exit(main) if $PROGRAM_NAME == __FILE__