Skip to content

Instantly share code, notes, and snippets.

@yokozawa
Created March 4, 2016 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yokozawa/13a79324b9ca620263ac to your computer and use it in GitHub Desktop.
Save yokozawa/13a79324b9ca620263ac to your computer and use it in GitHub Desktop.
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