Skip to content

Instantly share code, notes, and snippets.

@yokozawa

yokozawa/file_up.rb

Created Mar 4, 2016
Embed
What would you like to do?
file upload .rb to aws::s3
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
You can’t perform that action at this time.