class NiftycloudRestfulReadApi::NiftyCloud::Storage
Constants
- VERSION
Public Class Methods
new(options)
click to toggle source
# File lib/niftycloud-restful-read-api.rb, line 174 def initialize(options) @access_key_id = options[:access_key_id] @secret_access_key = options[:secret_access_key] if options[:region] == 'east-1' self.class.base_uri "https://ncss.nifty.com" else self.class.base_uri "https://#{options[:region]}-ncss.nifty.com" end end
Public Instance Methods
buckets()
click to toggle source
# File lib/niftycloud-restful-read-api.rb, line 184 def buckets @date = Time.now.rfc2822.gsub(/(\-|\+)\d{4}$/, 'GMT') response = self.class.get("/", :headers => headers) [response['ListAllMyBucketsResult']['Buckets']['Bucket']].flatten rescue [] end
headers()
click to toggle source
# File lib/niftycloud-restful-read-api.rb, line 190 def headers { 'authorization' => "NIFTY #{@access_key_id}:#{signature}", 'date' => @date, 'content-type' => 'text/plain' } end
signature()
click to toggle source
# File lib/niftycloud-restful-read-api.rb, line 198 def signature signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), @secret_access_key, string_to_sign)).strip end
string_to_sign()
click to toggle source
# File lib/niftycloud-restful-read-api.rb, line 202 def string_to_sign str = [] str << 'GET' str << '' str << 'text/plain' str << @date str << '/' str.join("\n") end