lib/fog/aws/models/storage/file.rb in fog-0.3.17 vs lib/fog/aws/models/storage/file.rb in fog-0.3.18
- old
+ new
@@ -3,21 +3,28 @@
module Fog
module AWS
class Storage
class File < Fog::Model
+ extend Fog::Deprecation
+ deprecate(:size, :content_length)
+ deprecate(:size=, :content_length=)
identity :key, :aliases => 'Key'
attr_writer :body
- attribute :content_length, :aliases => 'Content-Length'
- attribute :content_type, :aliases => 'Content-Type'
- attribute :etag, :aliases => ['Etag', 'ETag']
- attribute :last_modified, :aliases => ['Last-Modified', 'LastModified']
- attribute :owner, :aliases => 'Owner'
- attribute :size, :aliases => 'Size'
- attribute :storage_class, :aliases => 'StorageClass'
+ 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_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 :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']
unless valid_acls.include?(new_acl)
raise ArgumentError.new("acl must be one of [#{valid_acls.join(', ')}]")
@@ -78,17 +85,20 @@
def save(options = {})
requires :body, :directory, :key
if options != {}
Formatador.display_line("[yellow][WARN] options param is deprecated, use acl= instead[/] [light_black](#{caller.first})[/]")
end
- if @acl
- options['x-amz-acl'] ||= @acl
- end
- if content_type
- options['Content-Type'] = content_type
- end
+ options['x-amz-acl'] ||= @acl if @acl
+ options['Cache-Control'] = cache_control if cache_control
+ 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['x-amz-storage-class'] = storage_class if storage_class
+
data = connection.put_object(directory.key, @key, @body, options)
- @etag = data.headers['ETag']
+ merge_attributes(data.headers)
true
end
def url(expires)
requires :key