Created
January 26, 2013 07:57
-
-
Save yuyalush/4640900 to your computer and use it in GitHub Desktop.
ニフティクラウドストレージへ公開ファイルをアップロードする手抜きスクリプト。
NCSはS3互換なので、ライブラリがそのまま使えました。便利〜。
<注意>
西日本リージョンにバケットがある前提です。(東日本にバケットにあるときはエンドポイントを変えてください。)
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: "ACCESS_KEY", | |
secret_access_key: "SECRET_ACCESS_KEY", | |
s3_endpoint: "west-1-ncss.nifty.com" | |
) | |
(bucket_name, file_name) = ARGV | |
unless bucket_name && file_name | |
puts "Usage: upload_file.rb <BUCKET_NAME> <FILE_NAME>" | |
exit 1 | |
end | |
b = ncs.buckets[bucket_name] | |
o = b.objects[file_name] | |
o.write(:file => file_name, :acl => :public_read) | |
puts o.public_url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment