Skip to content

Instantly share code, notes, and snippets.

@yuyalush
Created January 26, 2013 07:57
Show Gist options
  • Save yuyalush/4640900 to your computer and use it in GitHub Desktop.
Save yuyalush/4640900 to your computer and use it in GitHub Desktop.
ニフティクラウドストレージへ公開ファイルをアップロードする手抜きスクリプト。 NCSはS3互換なので、ライブラリがそのまま使えました。便利〜。 <注意> 西日本リージョンにバケットがある前提です。(東日本にバケットにあるときはエンドポイントを変えてください。)
#
# 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