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

[aws|storage] add file metadata support

This commit is contained in:
geemus 2011-01-04 11:01:04 -08:00
parent 3fd9d13bc2
commit a888fe525b

View file

@ -21,6 +21,7 @@ module Fog
attribute :etag, :aliases => ['Etag', 'ETag']
attribute :expires, :aliases => 'Expires'
attribute :last_modified, :aliases => ['Last-Modified', 'LastModified']
attribute :metadata
attribute :owner, :aliases => 'Owner'
attribute :storage_class, :aliases => ['x-amz-storage-class', 'StorageClass']
@ -61,6 +62,16 @@ module Fog
true
end
remove_method :metadata
def metadata
attributes.reject {|key, value| !(key.to_s =~ /^x-amz-meta-/)}
end
remove_method :metadata=
def metadata=(new_metadata)
merge_attributes(new_metadata)
end
remove_method :owner=
def owner=(new_owner)
if new_owner
@ -105,6 +116,7 @@ module Fog
options['Content-MD5'] = content_md5 if content_md5
options['Content-Type'] = content_type if content_type
options['Expires'] = expires if expires
options.merge(metadata)
options['x-amz-storage-class'] = storage_class if storage_class
data = connection.put_object(directory.key, key, body, options)