mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|storage|] Make get_object_http_url use correct S3 host in returned URL
This fixes a previous typo in get_object_http_url to correctly use the configured AWS S3 host name in the URL and adds a test for the default case where the bucket name can be used as a DNS CNAME. For example, a bucket company-testbucket would translate into: http://company-testbucket./company-testbucket./fog_object?AWSAccessKeyId=... Which is now fixed into: http://company-testbucket.s3.amazonaws.com/fog_object?AWSAccessKeyId=...
This commit is contained in:
parent
2e6a50d370
commit
9de2caa488
2 changed files with 6 additions and 1 deletions
|
@ -12,7 +12,7 @@ module Fog
|
|||
raise ArgumentError.new('object_name is required')
|
||||
end
|
||||
host, path = if bucket_name =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
|
||||
["#{bucket_name}.#{host}", object_name]
|
||||
["#{bucket_name}.#{@host}", object_name]
|
||||
else
|
||||
[@host, "#{bucket_name}/#{object_name}"]
|
||||
end
|
||||
|
|
|
@ -83,6 +83,11 @@ Shindo.tests('AWS::Storage | object requests', ['aws']) do
|
|||
tests("#delete_object('#{@directory.identity}', 'fog_object')").succeeds do
|
||||
Fog::Storage[:aws].delete_object(@directory.identity, 'fog_object')
|
||||
end
|
||||
|
||||
tests("#get_object_http_url('#{@directory.identity}', 'fog_object', expiration timestamp)").returns(true) do
|
||||
object_url = Fog::Storage[:aws].get_object_http_url(@directory.identity, 'fog_object', (Time.now + 60))
|
||||
(object_url =~ /http:\/\/#{Regexp.quote(@directory.identity)}\.s3\.amazonaws\.com\/fog_object/) != nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue