lib/fog/aws/models/storage/file.rb in fog-0.3.34 vs lib/fog/aws/models/storage/file.rb in fog-0.4.0
- old
+ new
@@ -13,16 +13,17 @@
attr_writer :body
attribute :cache_control, :aliases => 'Cache-Control'
attribute :content_disposition, :aliases => 'Content-Disposition'
attribute :content_encoding, :aliases => 'Content-Encoding'
- attribute :content_length, :aliases => ['Content-Length', 'Size'], :type => :integer
+ attribute :content_length, :aliases => ['Content-Length', 'Size']
attribute :content_md5, :aliases => 'Content-MD5'
attribute :content_type, :aliases => 'Content-Type'
attribute :etag, :aliases => ['Etag', 'ETag']
attribute :expires, :aliases => 'Expires'
- attribute :last_modified, :aliases => ['Last-Modified', 'LastModified'], :type => :time
+ attribute :last_modified, :aliases => ['Last-Modified', 'LastModified']
+ attribute :metadata
attribute :owner, :aliases => 'Owner'
attribute :storage_class, :aliases => ['x-amz-storage-class', 'StorageClass']
def acl=(new_acl)
valid_acls = ['private', 'public-read', 'public-read-write', 'authenticated-read']
@@ -59,10 +60,20 @@
requires :directory, :key
connection.delete_object(directory.key, key)
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
attributes[:owner] = {
:display_name => new_owner['DisplayName'],
@@ -103,9 +114,10 @@
options['Content-Disposition'] = content_disposition if content_disposition
options['Content-Encoding'] = content_encoding if content_encoding
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)
merge_attributes(data.headers)
if body.is_a?(String)