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

[aws][storage] nicer acl setting mechanism

This commit is contained in:
geemus 2010-09-23 09:38:55 -07:00
parent 972c2792ea
commit 283a757a86

View file

@ -17,6 +17,14 @@ module Fog
attribute :size, :aliases => 'Size'
attribute :storage_class, :aliases => 'StorageClass'
def acl=(new_acl)
valid_acls = ['private', 'public-read', 'public-read-write', 'authenticated-read']
unless valid_acls.include?(new_acl)
raise ArgumentError.new("acl must be one of [#{valid_acls.join(', ')}]")
end
@acl = new_acl
end
def body
@body ||= if last_modified && (file = collection.get(identity))
file.body
@ -61,6 +69,9 @@ module Fog
def save(options = {})
requires :body, :directory, :key
if @acl
options['x-amz-acl'] = @acl
end
data = connection.put_object(directory.key, @key, @body, options)
@etag = data.headers['ETag']
true