Created
February 9, 2018 12:19
Revisions
-
db42 created this gist
Feb 9, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ require 'aws-sdk-s3' # v2: require 'aws-sdk' ACCESS_KEY_ID = "" SECRET_ACCESS_KEY = "" REGION_ID = "us-east-1" BUCKET_NAME = "bucket-name" def uploadS3 credentials = Aws::Credentials.new( ACCESS_KEY_ID, SECRET_ACCESS_KEY ) s3 = Aws::S3::Client.new( region: REGION_ID, credentials: credentials ) #Upload export/file1.zip, export/file2.zip for file_name in ['file1.zip', 'file2.zip'] name = File.join('export', file_name) # Upload File.open(name, 'rb') do |file| puts "start uploading #{file_name} to s3" resp = s3.put_object(bucket: BUCKET_NAME, acl: "public-read", key: file_name, body: file) puts resp end puts "File should be available at https://#{BUCKET_NAME}.s3.amazonaws.com/#{file_name}" end end