Skip to content

Instantly share code, notes, and snippets.

@yuyalush
Created July 19, 2013 08:49
Show Gist options
  • Save yuyalush/6037720 to your computer and use it in GitHub Desktop.
Save yuyalush/6037720 to your computer and use it in GitHub Desktop.
aws-sdkを使ってNCSSへファイルアップロード
source "https://rubygems.org"
gem "aws-sdk", "1.8.0"
#
# Nifty Cloud Strage fileuploader
# docs : http://docs.aws.amazon.com/AWSRubySDK/latest/frames.html
#
require "aws"
ncs = AWS::S3.new(
access_key_id: "-----------------",
secret_access_key: "-----------------",
s3_endpoint: "west-1-ncss.nifty.com"
)
(bucket_name, dir_name) = ARGV
unless bucket_name && dir_name
puts "Usage: upload_file.rb <BUCKET_NAME> <dir_name>"
exit 1
end
b = ncs.buckets[bucket_name]
Dir::chdir(dir_name)
Dir.glob("**/*").each do |f|
next if FileTest::directory?(f)
o = b.objects[f]
o.write(:file => f, :acl => :public_read)
puts o.public_url
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment