mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|storage] Assume body has #size, and maybe #path
This commit is contained in:
parent
71df6497ff
commit
eff1990db0
2 changed files with 4 additions and 11 deletions
|
@ -64,16 +64,14 @@ module Fog
|
|||
:headers => {}
|
||||
}
|
||||
|
||||
if data.is_a?(String)
|
||||
metadata[:body] = data
|
||||
metadata[:headers]['Content-Length'] = metadata[:body].size
|
||||
else
|
||||
metadata[:body] = data
|
||||
metadata[:headers]['Content-Length'] = data.size
|
||||
|
||||
if data.respond_to?(:path)
|
||||
filename = ::File.basename(data.path)
|
||||
unless (mime_types = MIME::Types.of(filename)).empty?
|
||||
metadata[:headers]['Content-Type'] = mime_types.first.content_type
|
||||
end
|
||||
metadata[:body] = data
|
||||
metadata[:headers]['Content-Length'] = ::File.size(data.path)
|
||||
end
|
||||
# metadata[:headers]['Content-MD5'] = Base64.encode64(Digest::MD5.digest(metadata[:body])).strip
|
||||
metadata
|
||||
|
|
|
@ -118,11 +118,6 @@ module Fog
|
|||
|
||||
data = connection.put_object(directory.key, key, body, options)
|
||||
merge_attributes(data.headers)
|
||||
if body.is_a?(String)
|
||||
self.content_length = body.size
|
||||
else
|
||||
self.content_length = ::File.size(body.path)
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue