mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
raise ArgumentError when lacking keys for get bucket/object
This commit is contained in:
parent
db54e424be
commit
3c78b6f166
2 changed files with 18 additions and 0 deletions
|
@ -34,6 +34,9 @@ unless Fog.mocking?
|
|||
# * 'Size'<~Integer> - Size of object
|
||||
# * 'StorageClass'<~String> - Storage class of object
|
||||
def get_bucket(bucket_name, options = {})
|
||||
unless bucket_name
|
||||
raise ArgumentError.new('bucket_name is required')
|
||||
end
|
||||
query = ''
|
||||
for key, value in options
|
||||
query << "#{key}=#{value};"
|
||||
|
@ -61,6 +64,9 @@ else
|
|||
|
||||
# FIXME: implement delimiter
|
||||
def get_bucket(bucket_name, options = {})
|
||||
unless bucket_name
|
||||
raise ArgumentError.new('bucket_name is required')
|
||||
end
|
||||
response = Fog::Response.new
|
||||
if bucket = Fog::AWS::S3.data[:buckets][bucket_name]
|
||||
response.status = 200
|
||||
|
|
|
@ -24,6 +24,12 @@ unless Fog.mocking?
|
|||
# * 'ETag'<~String> - Etag of object
|
||||
# * 'Last-Modified'<~String> - Last modified timestamp for object
|
||||
def get_object(bucket_name, object_name, options = {})
|
||||
unless bucket_name
|
||||
raise ArgumentError.new('bucket_name is required')
|
||||
end
|
||||
unless object_name
|
||||
raise ArgumentError.new('object_name is required')
|
||||
end
|
||||
headers = {}
|
||||
headers['If-Modified-Since'] = options['If-Modified-Since'].utc.strftime("%a, %d %b %Y %H:%M:%S +0000") if options['If-Modified-Since']
|
||||
headers['If-Unmodified-Since'] = options['If-Unmodified-Since'].utc.strftime("%a, %d %b %Y %H:%M:%S +0000") if options['If-Modified-Since']
|
||||
|
@ -48,6 +54,12 @@ else
|
|||
class S3
|
||||
|
||||
def get_object(bucket_name, object_name, options = {})
|
||||
unless bucket_name
|
||||
raise ArgumentError.new('bucket_name is required')
|
||||
end
|
||||
unless object_name
|
||||
raise ArgumentError.new('object_name is required')
|
||||
end
|
||||
response = Fog::Response.new
|
||||
if (bucket = Fog::AWS::S3.data[:buckets][bucket_name]) && (object = bucket[:objects][object_name])
|
||||
if options['If-Match'] && options['If-Match'] != object['ETag']
|
||||
|
|
Loading…
Reference in a new issue