1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[s3] cleaner mocking/dependencies

This commit is contained in:
geemus (Wesley Beary) 2010-03-13 13:37:24 -08:00
parent 51c8e69701
commit 46ea4a4a99
18 changed files with 241 additions and 310 deletions

View file

@ -1,11 +1,12 @@
require 'fog/aws/s3.rb'
module Fog module Fog
module AWS module AWS
def self.dependencies def self.dependencies
[ [
'fog/aws/ec2.rb', 'fog/aws/ec2.rb',
'fog/aws/simpledb.rb', 'fog/aws/simpledb.rb'
'fog/aws/s3.rb'
] ]
end end

View file

@ -1,9 +1,20 @@
require 'fog/collection'
require 'fog/aws/models/s3/directory'
module Fog module Fog
module AWS module AWS
class S3 module S3
def directories class Real
Fog::AWS::S3::Directories.new(:connection => self) def directories
Fog::AWS::S3::Directories.new(:connection => self)
end
end
class Mock
def directories
Fog::AWS::S3::Directories.new(:connection => self)
end
end end
class Directories < Fog::Collection class Directories < Fog::Collection

View file

@ -1,6 +1,9 @@
require 'fog/model'
require 'fog/aws/models/s3/files'
module Fog module Fog
module AWS module AWS
class S3 module S3
class Directory < Fog::Model class Directory < Fog::Model

View file

@ -1,6 +1,8 @@
require 'fog/model'
module Fog module Fog
module AWS module AWS
class S3 module S3
class File < Fog::Model class File < Fog::Model

View file

@ -1,6 +1,9 @@
require 'fog/collection'
require 'fog/aws/models/s3/file'
module Fog module Fog
module AWS module AWS
class S3 module S3
class Files < Fog::Collection class Files < Fog::Collection

View file

@ -1,8 +1,9 @@
unless Fog.mocking? module Fog
module AWS
module S3
class Real
module Fog require 'fog/aws/parsers/s3/copy_object'
module AWS
class S3
# Copy an object from one S3 bucket to another # Copy an object from one S3 bucket to another
# #
@ -38,20 +39,14 @@ unless Fog.mocking?
end end
end end
end
end
else class Mock
module Fog
module AWS
class S3
def copy_object(source_bucket_name, source_object_name, target_bucket_name, target_object_name, options = {}) def copy_object(source_bucket_name, source_object_name, target_bucket_name, target_object_name, options = {})
response = Excon::Response.new response = Excon::Response.new
source_bucket = Fog::AWS::S3.data[:buckets][source_bucket_name] source_bucket = @data[:buckets][source_bucket_name]
source_object = source_bucket && source_bucket[:objects][source_object_name] source_object = source_bucket && source_bucket[:objects][source_object_name]
target_bucket = Fog::AWS::S3.data[:buckets][target_bucket_name] target_bucket = @data[:buckets][target_bucket_name]
if source_object && target_bucket if source_object && target_bucket
response.status = 200 response.status = 200
@ -75,5 +70,4 @@ else
end end
end end
end end
end end

View file

@ -1,8 +1,7 @@
unless Fog.mocking? module Fog
module AWS
module Fog module S3
module AWS class Real
class S3
# Delete an S3 bucket # Delete an S3 bucket
# #
@ -22,32 +21,26 @@ unless Fog.mocking?
end end
end end
end
end
else class Mock
module Fog
module AWS
class S3
def delete_bucket(bucket_name) def delete_bucket(bucket_name)
response = Excon::Response.new response = Excon::Response.new
if Fog::AWS::S3.data[:buckets][bucket_name].nil? if @data[:buckets][bucket_name].nil?
response.status = 404 response.status = 404
raise(Excon::Errors.status_error({:expects => 204}, response)) raise(Excon::Errors.status_error({:expects => 204}, response))
elsif Fog::AWS::S3.data[:buckets][bucket_name] && !Fog::AWS::S3.data[:buckets][bucket_name][:objects].empty? elsif @data[:buckets][bucket_name] && !@data[:buckets][bucket_name][:objects].empty?
response.status = 409 response.status = 409
raise(Excon::Errors.status_error({:expects => 204}, response)) raise(Excon::Errors.status_error({:expects => 204}, response))
else else
Fog::AWS::S3.data[:buckets].delete(bucket_name) @data[:buckets].delete(bucket_name)
response.status = 204 response.status = 204
end end
response response
end end
end end
end end
end end
end end

View file

@ -1,8 +1,7 @@
unless Fog.mocking? module Fog
module AWS
module Fog module S3
module AWS class Real
class S3
# Delete an object from S3 # Delete an object from S3
# #
@ -25,18 +24,12 @@ unless Fog.mocking?
end end
end end
end
end
else class Mock
module Fog
module AWS
class S3
def delete_object(bucket_name, object_name) def delete_object(bucket_name, object_name)
response = Excon::Response.new response = Excon::Response.new
if bucket = Fog::AWS::S3.data[:buckets][bucket_name] if bucket = @data[:buckets][bucket_name]
response.status = 204 response.status = 204
bucket[:objects].delete(object_name) bucket[:objects].delete(object_name)
else else
@ -49,5 +42,4 @@ else
end end
end end
end end
end end

View file

@ -1,8 +1,9 @@
unless Fog.mocking? module Fog
module AWS
module S3
class Real
module Fog require 'fog/aws/parsers/s3/get_bucket'
module AWS
class S3
# List information about objects in an S3 bucket # List information about objects in an S3 bucket
# #
@ -54,14 +55,8 @@ unless Fog.mocking?
end end
end end
end
end
else class Mock
module Fog
module AWS
class S3
# FIXME: implement delimiter # FIXME: implement delimiter
def get_bucket(bucket_name, options = {}) def get_bucket(bucket_name, options = {})
@ -69,16 +64,17 @@ else
raise ArgumentError.new('bucket_name is required') raise ArgumentError.new('bucket_name is required')
end end
response = Excon::Response.new response = Excon::Response.new
if bucket = Fog::AWS::S3.data[:buckets][bucket_name] if bucket = @data[:buckets][bucket_name]
response.status = 200 response.status = 200
response.body = { response.body = {
'Contents' => bucket[:objects].values.sort {|x,y| x['Key'] <=> y['Key']}.reject do |object| 'Contents' => bucket[:objects].values.sort {|x,y| x['Key'] <=> y['Key']}.reject do |object|
(options['prefix'] && object['Key'][0...options['prefix'].length] != options['prefix']) || (options['prefix'] && object['Key'][0...options['prefix'].length] != options['prefix']) ||
(options['marker'] && object['Key'] <= options['marker']) (options['marker'] && object['Key'] <= options['marker'])
end.map do |object| end.map do |object|
data = object.reject {|key, value| !['ETag', 'Key', 'LastModified', 'Owner', 'Size', 'StorageClass'].include?(key)} data = object.reject {|key, value| !['ETag', 'Key', 'LastModified', 'Size', 'StorageClass'].include?(key)}
data.merge!({ data.merge!({
'LastModified' => Time.parse(data['LastModified']), 'LastModified' => Time.parse(data['LastModified']),
'Owner' => bucket['Owner'],
'Size' => data['Size'].to_i 'Size' => data['Size'].to_i
}) })
data data
@ -103,5 +99,4 @@ else
end end
end end
end end
end end

View file

@ -1,8 +1,9 @@
unless Fog.mocking? module Fog
module AWS
module S3
class Real
module Fog require 'fog/aws/parsers/s3/get_bucket_location'
module AWS
class S3
# Get location constraint for an S3 bucket # Get location constraint for an S3 bucket
# #
@ -26,18 +27,12 @@ unless Fog.mocking?
end end
end end
end
end
else class Mock
module Fog
module AWS
class S3
def get_bucket_location(bucket_name) def get_bucket_location(bucket_name)
response = Excon::Response.new response = Excon::Response.new
if bucket = Fog::AWS::S3.data[:buckets][bucket_name] if bucket = @data[:buckets][bucket_name]
response.status = 200 response.status = 200
response.body = {'LocationConstraint' => bucket['LocationConstraint'] } response.body = {'LocationConstraint' => bucket['LocationConstraint'] }
else else
@ -50,5 +45,4 @@ else
end end
end end
end end
end end

View file

@ -1,8 +1,7 @@
unless Fog.mocking? module Fog
module AWS
module Fog module S3
module AWS class Real
class S3
# Get an object from S3 # Get an object from S3
# #
@ -56,19 +55,13 @@ unless Fog.mocking?
:headers => {}, :headers => {},
:host => "#{bucket_name}.#{@host}", :host => "#{bucket_name}.#{@host}",
:method => 'GET', :method => 'GET',
:path => object_name :path => CGI.escape(object_name)
}, expires) }, expires)
end end
end end
end
end
else class Mock
module Fog
module AWS
class S3
def get_object(bucket_name, object_name, options = {}, &block) def get_object(bucket_name, object_name, options = {}, &block)
unless bucket_name unless bucket_name
@ -78,7 +71,7 @@ else
raise ArgumentError.new('object_name is required') raise ArgumentError.new('object_name is required')
end end
response = Excon::Response.new response = Excon::Response.new
if (bucket = Fog::AWS::S3.data[:buckets][bucket_name]) && (object = bucket[:objects][object_name]) if (bucket = @data[:buckets][bucket_name]) && (object = bucket[:objects][object_name])
if options['If-Match'] && options['If-Match'] != object['ETag'] if options['If-Match'] && options['If-Match'] != object['ETag']
response.status = 412 response.status = 412
elsif options['If-Modified-Since'] && options['If-Modified-Since'] > Time.parse(object['LastModified']) elsif options['If-Modified-Since'] && options['If-Modified-Since'] > Time.parse(object['LastModified'])
@ -121,5 +114,4 @@ else
end end
end end
end end
end end

View file

@ -1,8 +1,9 @@
unless Fog.mocking? module Fog
module AWS
module S3
class Real
module Fog require 'fog/aws/parsers/s3/get_request_payment'
module AWS
class S3
# Get configured payer for an S3 bucket # Get configured payer for an S3 bucket
# #
@ -26,18 +27,12 @@ unless Fog.mocking?
end end
end end
end
end
else class Mock
module Fog
module AWS
class S3
def get_request_payment(bucket_name) def get_request_payment(bucket_name)
response = Excon::Response.new response = Excon::Response.new
if bucket = Fog::AWS::S3.data[:buckets][bucket_name] if bucket = @data[:buckets][bucket_name]
response.status = 200 response.status = 200
response.body = { 'Payer' => bucket['Payer'] } response.body = { 'Payer' => bucket['Payer'] }
else else
@ -50,5 +45,4 @@ else
end end
end end
end end
end end

View file

@ -1,8 +1,9 @@
unless Fog.mocking? module Fog
module AWS
module S3
class Real
module Fog require 'fog/aws/parsers/s3/get_service'
module AWS
class S3
# List information about S3 buckets for authorized user # List information about S3 buckets for authorized user
# #
@ -28,19 +29,13 @@ unless Fog.mocking?
end end
end end
end
end
else class Mock
module Fog
module AWS
class S3
def get_service def get_service
response = Excon::Response.new response = Excon::Response.new
response.headers['Status'] = 200 response.headers['Status'] = 200
buckets = Fog::AWS::S3.data[:buckets].values.map do |bucket| buckets = @data[:buckets].values.map do |bucket|
bucket.reject do |key, value| bucket.reject do |key, value|
!['CreationDate', 'Name'].include?(key) !['CreationDate', 'Name'].include?(key)
end end
@ -55,5 +50,4 @@ else
end end
end end
end end
end end

View file

@ -1,8 +1,7 @@
unless Fog.mocking? module Fog
module AWS
module Fog module S3
module AWS class Real
class S3
# Get headers for an object from S3 # Get headers for an object from S3
# #
@ -39,14 +38,8 @@ unless Fog.mocking?
end end
end end
end
end
else class Mock
module Fog
module AWS
class S3
def head_object(bucket_name, object_name, options = {}) def head_object(bucket_name, object_name, options = {})
response = get_object(bucket_name, object_name, options) response = get_object(bucket_name, object_name, options)
@ -57,5 +50,4 @@ else
end end
end end
end end
end end

View file

@ -1,8 +1,7 @@
unless Fog.mocking? module Fog
module AWS
module Fog module S3
module AWS class Real
class S3
# Create an S3 bucket # Create an S3 bucket
# #
@ -17,11 +16,11 @@ unless Fog.mocking?
def put_bucket(bucket_name, options = {}) def put_bucket(bucket_name, options = {})
if options['LocationConstraint'] if options['LocationConstraint']
data = data =
<<-DATA <<-DATA
<CreateBucketConfiguration> <CreateBucketConfiguration>
<LocationConstraint>#{options['LocationConstraint']}</LocationConstraint> <LocationConstraint>#{options['LocationConstraint']}</LocationConstraint>
</CreateBucketConfiguration> </CreateBucketConfiguration>
DATA DATA
else else
data = nil data = nil
end end
@ -36,14 +35,8 @@ unless Fog.mocking?
end end
end end
end
end
else class Mock
module Fog
module AWS
class S3
def put_bucket(bucket_name, options = {}) def put_bucket(bucket_name, options = {})
response = Excon::Response.new response = Excon::Response.new
@ -60,8 +53,8 @@ else
else else
bucket['LocationConstraint'] = '' bucket['LocationConstraint'] = ''
end end
unless Fog::AWS::S3.data[:buckets][bucket_name] unless @data[:buckets][bucket_name]
Fog::AWS::S3.data[:buckets][bucket_name] = bucket @data[:buckets][bucket_name] = bucket
end end
response response
end end
@ -69,5 +62,4 @@ else
end end
end end
end end
end end

View file

@ -1,8 +1,7 @@
unless Fog.mocking? module Fog
module AWS
module Fog module S3
module AWS class Real
class S3
# Create an object in an S3 bucket # Create an object in an S3 bucket
# #
@ -25,7 +24,7 @@ unless Fog.mocking?
# * headers<~Hash>: # * headers<~Hash>:
# * 'ETag'<~String> - etag of new object # * 'ETag'<~String> - etag of new object
def put_object(bucket_name, object_name, data, options = {}) def put_object(bucket_name, object_name, data, options = {})
data = parse_data(data) data = Fog::AWS::S3.parse_data(data)
headers = data[:headers].merge!(options) headers = data[:headers].merge!(options)
request({ request({
:body => data[:body], :body => data[:body],
@ -39,19 +38,13 @@ unless Fog.mocking?
end end
end end
end
end
else class Mock
module Fog
module AWS
class S3
def put_object(bucket_name, object_name, data, options = {}) def put_object(bucket_name, object_name, data, options = {})
data = parse_data(data) data = Fog::AWS::S3.parse_data(data)
response = Excon::Response.new response = Excon::Response.new
if (bucket = Fog::AWS::S3.data[:buckets][bucket_name]) if (bucket = @data[:buckets][bucket_name])
response.status = 200 response.status = 200
bucket[:objects][object_name] = { bucket[:objects][object_name] = {
:body => data[:body], :body => data[:body],
@ -72,5 +65,4 @@ else
end end
end end
end end
end end

View file

@ -1,8 +1,7 @@
unless Fog.mocking? module Fog
module AWS
module Fog module S3
module AWS class Real
class S3
# Change who pays for requests to an S3 bucket # Change who pays for requests to an S3 bucket
# #
@ -27,18 +26,12 @@ DATA
end end
end end
end
end
else class Mock
module Fog
module AWS
class S3
def put_request_payment(bucket_name, payer) def put_request_payment(bucket_name, payer)
response = Excon::Response.new response = Excon::Response.new
if bucket = Fog::AWS::S3.data[:buckets][bucket_name] if bucket = @data[:buckets][bucket_name]
response.status = 200 response.status = 200
bucket['Payer'] = payer bucket['Payer'] = payer
else else
@ -51,6 +44,4 @@ else
end end
end end
end end
end end

View file

@ -1,82 +1,33 @@
require 'fog/aws/models/s3/directories'
require 'fog/aws/models/s3/directory'
require 'fog/aws/models/s3/files'
require 'fog/aws/models/s3/file'
require 'fog/aws/requests/s3/copy_object'
require 'fog/aws/requests/s3/delete_bucket'
require 'fog/aws/requests/s3/delete_object'
require 'fog/aws/requests/s3/get_bucket'
require 'fog/aws/requests/s3/get_bucket_location'
require 'fog/aws/requests/s3/get_object'
require 'fog/aws/requests/s3/get_request_payment'
require 'fog/aws/requests/s3/get_service'
require 'fog/aws/requests/s3/head_object'
require 'fog/aws/requests/s3/put_bucket'
require 'fog/aws/requests/s3/put_object'
require 'fog/aws/requests/s3/put_request_payment'
module Fog module Fog
module AWS module AWS
class S3 module S3
if Fog.mocking? def self.new(options={})
def self.reset_data
@data = { :buckets => {} }
end
def self.data
@data
end
end
def self.dependencies
[
"fog/aws/models/s3/directory.rb",
"fog/aws/models/s3/directories.rb",
"fog/aws/models/s3/file.rb",
"fog/aws/models/s3/files.rb",
"fog/aws/parsers/s3/copy_object.rb",
"fog/aws/parsers/s3/get_bucket.rb",
"fog/aws/parsers/s3/get_bucket_location.rb",
"fog/aws/parsers/s3/get_request_payment.rb",
"fog/aws/parsers/s3/get_service.rb",
"fog/aws/requests/s3/copy_object.rb",
"fog/aws/requests/s3/delete_bucket.rb",
"fog/aws/requests/s3/delete_object.rb",
"fog/aws/requests/s3/get_bucket.rb",
"fog/aws/requests/s3/get_bucket_location.rb",
"fog/aws/requests/s3/get_object.rb",
"fog/aws/requests/s3/get_request_payment.rb",
"fog/aws/requests/s3/get_service.rb",
"fog/aws/requests/s3/head_object.rb",
"fog/aws/requests/s3/put_bucket.rb",
"fog/aws/requests/s3/put_object.rb",
"fog/aws/requests/s3/put_request_payment.rb"
]
end
def self.reload
self.dependencies.each {|dependency| load(dependency)}
if Fog.mocking? if Fog.mocking?
reset_data Fog::AWS::S3::Mock.new(options)
else
Fog::AWS::S3::Real.new(options)
end end
end end
# Initialize connection to S3 def self.parse_data(data)
#
# ==== Notes
# options parameter must include values for :aws_access_key_id and
# :aws_secret_access_key in order to create a connection
#
# ==== Examples
# s3 = S3.new(
# :aws_access_key_id => your_aws_access_key_id,
# :aws_secret_access_key => your_aws_secret_access_key
# )
#
# ==== Parameters
# * options<~Hash> - config arguments for connection. Defaults to {}.
#
# ==== Returns
# * S3 object with connection to aws.
def initialize(options={})
unless @aws_access_key_id = options[:aws_access_key_id]
raise ArgumentError.new('aws_access_key_id is required to access ec2')
end
unless @aws_secret_access_key = options[:aws_secret_access_key]
raise ArgumentError.new('aws_secret_access_key is required to access ec2')
end
@hmac = HMAC::SHA1.new(@aws_secret_access_key)
@host = options[:host] || 's3.amazonaws.com'
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
end
private
def parse_data(data)
metadata = { metadata = {
:body => nil, :body => nil,
:headers => {} :headers => {}
@ -97,27 +48,64 @@ module Fog
metadata metadata
end end
def request(params) class Mock
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
params[:headers]['Date'] = Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S +0000")
params[:headers]['Authorization'] = "AWS #{@aws_access_key_id}:#{signature(params)}"
response = @connection.request(params) def reset_data
@data = { :buckets => {} }
end
def initialize(options={})
reset_data
end
response
end end
def url(params, expires) class Real
params[:headers]['Date'] = expires.to_i
query = [params[:query]].compact
query << "AWSAccessKeyId=#{@aws_access_key_id}"
query << "Signature=#{CGI.escape(signature(params))}"
query << "Expires=#{params[:headers]['Date']}"
"http://#{params[:host]}/#{params[:path]}?#{query.join('&')}"
end
def signature(params) # Initialize connection to S3
string_to_sign = #
# ==== Notes
# options parameter must include values for :aws_access_key_id and
# :aws_secret_access_key in order to create a connection
#
# ==== Examples
# s3 = S3.new(
# :aws_access_key_id => your_aws_access_key_id,
# :aws_secret_access_key => your_aws_secret_access_key
# )
#
# ==== Parameters
# * options<~Hash> - config arguments for connection. Defaults to {}.
#
# ==== Returns
# * S3 object with connection to aws.
def initialize(options={})
unless @aws_access_key_id = options[:aws_access_key_id]
raise ArgumentError.new('aws_access_key_id is required to access ec2')
end
unless @aws_secret_access_key = options[:aws_secret_access_key]
raise ArgumentError.new('aws_secret_access_key is required to access ec2')
end
@hmac = HMAC::SHA1.new(@aws_secret_access_key)
@host = options[:host] || 's3.amazonaws.com'
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
end
private
def request(params)
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
params[:headers]['Date'] = Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S +0000")
params[:headers]['Authorization'] = "AWS #{@aws_access_key_id}:#{signature(params)}"
response = @connection.request(params)
response
end
def signature(params)
string_to_sign =
<<-DATA <<-DATA
#{params[:method]} #{params[:method]}
#{params[:headers]['Content-MD5']} #{params[:headers]['Content-MD5']}
@ -125,46 +113,54 @@ module Fog
#{params[:headers]['Date']} #{params[:headers]['Date']}
DATA DATA
amz_headers, canonical_amz_headers = {}, '' amz_headers, canonical_amz_headers = {}, ''
for key, value in params[:headers] for key, value in params[:headers]
if key[0..5] == 'x-amz-' if key[0..5] == 'x-amz-'
amz_headers[key] = value amz_headers[key] = value
end
end end
end amz_headers = amz_headers.sort {|x, y| x[0] <=> y[0]}
amz_headers = amz_headers.sort {|x, y| x[0] <=> y[0]} for pair in amz_headers
for pair in amz_headers canonical_amz_headers << "#{pair[0]}:#{pair[1]}\n"
canonical_amz_headers << "#{pair[0]}:#{pair[1]}\n"
end
string_to_sign << "#{canonical_amz_headers}"
subdomain = params[:host].split(".#{@host}").first
unless subdomain =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
puts("[WARN] fog: the specified s3 bucket name(#{subdomain}) is not a valid dns name. See: http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?Introduction.html")
params[:host] = params[:host].split("#{subdomain}.")[-1]
if params[:path]
params[:path] = "#{subdomain}/#{params[:path]}"
else
params[:path] = "#{subdomain}"
end end
subdomain = nil string_to_sign << "#{canonical_amz_headers}"
subdomain = params[:host].split(".#{@host}").first
unless subdomain =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
puts("[WARN] fog: the specified s3 bucket name(#{subdomain}) is not a valid dns name. See: http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?Introduction.html")
params[:host] = params[:host].split("#{subdomain}.")[-1]
if params[:path]
params[:path] = "#{subdomain}/#{params[:path]}"
else
params[:path] = "#{subdomain}"
end
subdomain = nil
end
canonical_resource = "/"
unless subdomain.nil? || subdomain == @host
canonical_resource << "#{CGI.escape(subdomain).downcase}/"
end
canonical_resource << "#{params[:path]}"
if ['acl', 'location', 'logging', 'requestPayment', 'torrent'].include?(params[:query])
canonical_resource << "?#{params[:query]}"
end
string_to_sign << "#{canonical_resource}"
hmac = @hmac.update(string_to_sign)
signature = Base64.encode64(hmac.digest).chomp!
end end
canonical_resource = "/" def url(params, expires)
unless subdomain.nil? || subdomain == @host params[:headers]['Date'] = expires.to_i
canonical_resource << "#{CGI.escape(subdomain).downcase}/" query = [params[:query]].compact
query << "AWSAccessKeyId=#{@aws_access_key_id}"
query << "Signature=#{CGI.escape(signature(params))}"
query << "Expires=#{params[:headers]['Date']}"
"http://#{params[:host]}/#{params[:path]}?#{query.join('&')}"
end end
canonical_resource << "#{params[:path]}"
if ['acl', 'location', 'logging', 'requestPayment', 'torrent'].include?(params[:query])
canonical_resource << "?#{params[:query]}"
end
string_to_sign << "#{canonical_resource}"
hmac = @hmac.update(string_to_sign)
signature = Base64.encode64(hmac.digest).chomp!
end end
end end
end end
end end
Fog::AWS::S3.reload