mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #3185 from CpuID/master
add missing HEAD Bucket request, with a basic test in there
This commit is contained in:
commit
1c6f8d146d
3 changed files with 43 additions and 0 deletions
38
lib/fog/aws/requests/storage/head_bucket.rb
Normal file
38
lib/fog/aws/requests/storage/head_bucket.rb
Normal file
|
@ -0,0 +1,38 @@
|
|||
module Fog
|
||||
module Storage
|
||||
class AWS
|
||||
class Real
|
||||
# Get headers for an S3 bucket, used to verify if it exists and if you have permission to access it
|
||||
#
|
||||
# @param bucket_name [String] Name of bucket to read from
|
||||
#
|
||||
# @return [Excon::Response] 200 response implies it exists, 404 does not exist, 403 no permissions
|
||||
# * body [String] Empty
|
||||
# * headers [Hash]:
|
||||
# * Content-Type [String] - MIME type of object
|
||||
#
|
||||
# @see http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketHEAD.html
|
||||
#
|
||||
def head_bucket(bucket_name)
|
||||
unless bucket_name
|
||||
raise ArgumentError.new('bucket_name is required')
|
||||
end
|
||||
request({
|
||||
:expects => 200,
|
||||
:bucket_name => bucket_name,
|
||||
:idempotent => true,
|
||||
:method => 'HEAD',
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
class Mock # :nodoc:all
|
||||
def head_bucket(bucket_name)
|
||||
response = get_bucket(bucket_name)
|
||||
response.body = nil
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -85,6 +85,7 @@ module Fog
|
|||
request :get_object_url
|
||||
request :get_request_payment
|
||||
request :get_service
|
||||
request :head_bucket
|
||||
request :head_object
|
||||
request :initiate_multipart_upload
|
||||
request :list_multipart_uploads
|
||||
|
|
|
@ -66,6 +66,10 @@ Shindo.tests('Fog::Storage[:aws] | bucket requests', ["aws"]) do
|
|||
Fog::Storage[:aws].get_bucket(@aws_bucket_name).body
|
||||
end
|
||||
|
||||
tests("#head_bucket('#{@aws_bucket_name}')").succeeds do
|
||||
Fog::Storage[:aws].head_bucket(@aws_bucket_name)
|
||||
end
|
||||
|
||||
file.destroy
|
||||
|
||||
file1 = Fog::Storage[:aws].directories.get(@aws_bucket_name).files.create(:body => 'a', :key => 'a/a1/file1')
|
||||
|
|
Loading…
Add table
Reference in a new issue