Created
March 4, 2016 08:20
-
-
Save yokozawa/13a79324b9ca620263ac to your computer and use it in GitHub Desktop.
file upload .rb to aws::s3
This file contains 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 characters
require 'aws-sdk' | |
require 'date' | |
p "start:#{Time.now.to_s}" | |
Aws.config.update({ | |
region: "ap-northeast-1", | |
credentials: Aws::Credentials.new("your-aws-key", "your-aws-secret") | |
}) | |
s3 = Aws::S3::Resource.new | |
today = (Date.today).strftime("%Y%m%d") | |
base_dir = "/home/xxx-ftp" | |
Dir.chdir(base_dir) | |
Dir.glob("#{today}*.txt").each do |file| | |
obj = s3.bucket('xxx-ftp').object(file) | |
obj.upload_file("#{base_dir}/#{file}") | |
end | |
p "end:#{Time.now.to_s}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment