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:
parent
972c2792ea
commit
283a757a86
1 changed files with 11 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue