From 808cd318eee138342e54c293c384c5645eb38822 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sun, 13 Sep 2015 22:56:29 -0400 Subject: [PATCH] Plop this on S3 already --- .gitignore | 2 ++ Gemfile | 2 ++ Gemfile.lock | 18 ++++++++++++++++++ mini_s3put.rb | 12 ++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 .gitignore create mode 100644 mini_s3put.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..02c1928 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.*env +*.csv diff --git a/Gemfile b/Gemfile index 6251230..0847425 100644 --- a/Gemfile +++ b/Gemfile @@ -2,5 +2,7 @@ source 'https://rubygems.org' ruby '2.2.2' if ENV.key?('DYNO') +gem 'aws-sdk', '~> 2' gem 'puma' +gem 'pry', group: [:development, :test] gem 'sinatra' diff --git a/Gemfile.lock b/Gemfile.lock index f75a438..4129877 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,21 @@ GEM remote: https://rubygems.org/ specs: + aws-sdk (2.1.20) + aws-sdk-resources (= 2.1.20) + aws-sdk-core (2.1.20) + jmespath (~> 1.0) + aws-sdk-resources (2.1.20) + aws-sdk-core (= 2.1.20) + coderay (1.1.0) + jmespath (1.0.2) + multi_json (~> 1.0) + method_source (0.8.2) + multi_json (1.11.2) + pry (0.10.1) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) puma (2.13.4) rack (1.6.4) rack-protection (1.5.3) @@ -9,12 +24,15 @@ GEM rack (~> 1.4) rack-protection (~> 1.4) tilt (>= 1.3, < 3) + slop (3.6.0) tilt (2.0.1) PLATFORMS ruby DEPENDENCIES + aws-sdk (~> 2) + pry puma sinatra diff --git a/mini_s3put.rb b/mini_s3put.rb new file mode 100644 index 0000000..c74fb2f --- /dev/null +++ b/mini_s3put.rb @@ -0,0 +1,12 @@ +require 'aws-sdk' + +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' +)