From 99d2920372f54bf49e3bbc92c5b4ce62c1f549f1 Mon Sep 17 00:00:00 2001 From: geemus Date: Fri, 24 Sep 2010 11:32:48 -0700 Subject: [PATCH] [aws][storage] more robust object url generation, also fixes non-standard regions and defaults to https --- lib/fog/aws/requests/storage/get_object_url.rb | 8 ++++---- lib/fog/aws/requests/storage/put_object_url.rb | 8 ++++---- lib/fog/aws/storage.rb | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/fog/aws/requests/storage/get_object_url.rb b/lib/fog/aws/requests/storage/get_object_url.rb index ff0f09b54..f3ac626d5 100644 --- a/lib/fog/aws/requests/storage/get_object_url.rb +++ b/lib/fog/aws/requests/storage/get_object_url.rb @@ -23,9 +23,9 @@ module Fog end url({ :headers => {}, - :host => "#{bucket_name}.#{@host}", + :host => @host, :method => 'GET', - :path => CGI.escape(object_name) + :path => [bucket_name, CGI.escape(object_name)].join('/') }, expires) end @@ -42,9 +42,9 @@ module Fog end url({ :headers => {}, - :host => "#{bucket_name}.#{@host}", + :host => @host, :method => 'GET', - :path => CGI.escape(object_name) + :path => [bucket_name, CGI.escape(object_name)].join('/') }, expires) end diff --git a/lib/fog/aws/requests/storage/put_object_url.rb b/lib/fog/aws/requests/storage/put_object_url.rb index 75031768d..aadefa7b8 100644 --- a/lib/fog/aws/requests/storage/put_object_url.rb +++ b/lib/fog/aws/requests/storage/put_object_url.rb @@ -23,9 +23,9 @@ module Fog end url({ :headers => {}, - :host => "#{bucket_name}.#{@host}", + :host => @host, :method => 'PUT', - :path => CGI.escape(object_name) + :path => [bucket_name, CGI.escape(object_name)].join('/') }, expires) end @@ -42,9 +42,9 @@ module Fog end url({ :headers => {}, - :host => "#{bucket_name}.#{@host}", + :host => @host, :method => 'PUT', - :path => CGI.escape(object_name) + :path => [bucket_name, CGI.escape(object_name)].join('/') }, expires) end diff --git a/lib/fog/aws/storage.rb b/lib/fog/aws/storage.rb index a51fc85f0..909b68d87 100644 --- a/lib/fog/aws/storage.rb +++ b/lib/fog/aws/storage.rb @@ -64,7 +64,8 @@ module Fog query << "AWSAccessKeyId=#{@aws_access_key_id}" query << "Signature=#{CGI.escape(signature(params))}" query << "Expires=#{params[:headers]['Date']}" - "http://#{params[:host]}/#{params[:path]}?#{query.join('&')}" + bucket = params[:host].split('.').first + "https://#{@host}/#{params[:path]}?#{query.join('&')}" end end