mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
parent
db42fae89a
commit
597acf0363
5 changed files with 9 additions and 16 deletions
|
@ -22,12 +22,14 @@ module Fog
|
|||
end
|
||||
|
||||
def self.get_body_size(body)
|
||||
case
|
||||
when body.respond_to?(:bytesize)
|
||||
if body.respond_to?(:force_encoding)
|
||||
body.force_encoding('BINARY')
|
||||
end
|
||||
if body.respond_to?(:bytesize)
|
||||
body.bytesize
|
||||
when body.respond_to?(:size)
|
||||
elsif body.respond_to?(:size)
|
||||
body.size
|
||||
when body.respond_to?(:stat)
|
||||
elsif body.respond_to?(:stat)
|
||||
body.stat.size
|
||||
else
|
||||
0
|
||||
|
|
|
@ -117,7 +117,6 @@ module Fog
|
|||
options['x-amz-storage-class'] = storage_class if storage_class
|
||||
|
||||
data = connection.put_object(directory.key, key, body, options)
|
||||
data.headers.delete('Content-Length')
|
||||
data.headers['ETag'].gsub!('"','')
|
||||
merge_attributes(data.headers)
|
||||
self.content_length = Fog::Storage.get_body_size(body)
|
||||
|
|
|
@ -119,11 +119,7 @@ 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
|
||||
self.content_length = Fog::Storage.get_body_size(body)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ module Fog
|
|||
end
|
||||
file.close
|
||||
merge_attributes(
|
||||
:content_length => ::File.size(path),
|
||||
:content_length => Fog::Storage.get_body_size(body),
|
||||
:last_modified => ::File.mtime(path)
|
||||
)
|
||||
true
|
||||
|
|
|
@ -60,11 +60,7 @@ module Fog
|
|||
options['Content-Type'] = content_type if content_type
|
||||
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
|
||||
self.content_length = Fog::Storage.get_body_size(body)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue