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
|
end
|
||||||
|
|
||||||
def self.get_body_size(body)
|
def self.get_body_size(body)
|
||||||
case
|
if body.respond_to?(:force_encoding)
|
||||||
when body.respond_to?(:bytesize)
|
body.force_encoding('BINARY')
|
||||||
|
end
|
||||||
|
if body.respond_to?(:bytesize)
|
||||||
body.bytesize
|
body.bytesize
|
||||||
when body.respond_to?(:size)
|
elsif body.respond_to?(:size)
|
||||||
body.size
|
body.size
|
||||||
when body.respond_to?(:stat)
|
elsif body.respond_to?(:stat)
|
||||||
body.stat.size
|
body.stat.size
|
||||||
else
|
else
|
||||||
0
|
0
|
||||||
|
|
|
@ -117,7 +117,6 @@ module Fog
|
||||||
options['x-amz-storage-class'] = storage_class if storage_class
|
options['x-amz-storage-class'] = storage_class if storage_class
|
||||||
|
|
||||||
data = connection.put_object(directory.key, key, body, options)
|
data = connection.put_object(directory.key, key, body, options)
|
||||||
data.headers.delete('Content-Length')
|
|
||||||
data.headers['ETag'].gsub!('"','')
|
data.headers['ETag'].gsub!('"','')
|
||||||
merge_attributes(data.headers)
|
merge_attributes(data.headers)
|
||||||
self.content_length = Fog::Storage.get_body_size(body)
|
self.content_length = Fog::Storage.get_body_size(body)
|
||||||
|
|
|
@ -119,11 +119,7 @@ module Fog
|
||||||
|
|
||||||
data = connection.put_object(directory.key, key, body, options)
|
data = connection.put_object(directory.key, key, body, options)
|
||||||
merge_attributes(data.headers)
|
merge_attributes(data.headers)
|
||||||
if body.is_a?(String)
|
self.content_length = Fog::Storage.get_body_size(body)
|
||||||
self.content_length = body.size
|
|
||||||
else
|
|
||||||
self.content_length = ::File.size(body.path)
|
|
||||||
end
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ module Fog
|
||||||
end
|
end
|
||||||
file.close
|
file.close
|
||||||
merge_attributes(
|
merge_attributes(
|
||||||
:content_length => ::File.size(path),
|
:content_length => Fog::Storage.get_body_size(body),
|
||||||
:last_modified => ::File.mtime(path)
|
:last_modified => ::File.mtime(path)
|
||||||
)
|
)
|
||||||
true
|
true
|
||||||
|
|
|
@ -60,11 +60,7 @@ module Fog
|
||||||
options['Content-Type'] = content_type if content_type
|
options['Content-Type'] = content_type if content_type
|
||||||
data = connection.put_object(directory.key, key, body, options)
|
data = connection.put_object(directory.key, key, body, options)
|
||||||
merge_attributes(data.headers)
|
merge_attributes(data.headers)
|
||||||
if body.is_a?(String)
|
self.content_length = Fog::Storage.get_body_size(body)
|
||||||
self.content_length = body.size
|
|
||||||
else
|
|
||||||
self.content_length = ::File.size(body.path)
|
|
||||||
end
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue