Created
July 19, 2013 08:49
-
-
Save yuyalush/6037720 to your computer and use it in GitHub Desktop.
aws-sdkを使ってNCSSへファイルアップロード
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 characters
source "https://rubygems.org" | |
gem "aws-sdk", "1.8.0" |
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 characters
# | |
# 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