From a888fe525b318f493da21e803302082f9718cf96 Mon Sep 17 00:00:00 2001 From: geemus Date: Tue, 4 Jan 2011 11:01:04 -0800 Subject: [PATCH] [aws|storage] add file metadata support --- lib/fog/aws/models/storage/file.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/fog/aws/models/storage/file.rb b/lib/fog/aws/models/storage/file.rb index 06df53bc9..e3b58b9f5 100644 --- a/lib/fog/aws/models/storage/file.rb +++ b/lib/fog/aws/models/storage/file.rb @@ -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)