mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Update put_object to accept blocks, and remove deprecation message.
This commit is contained in:
parent
275e9599ae
commit
dab0fcc33f
2 changed files with 13 additions and 2 deletions
|
@ -13,7 +13,7 @@ module Fog
|
||||||
unless block_given?
|
unless block_given?
|
||||||
if (parser = params.delete(:parser))
|
if (parser = params.delete(:parser))
|
||||||
body = Nokogiri::XML::SAX::PushParser.new(parser)
|
body = Nokogiri::XML::SAX::PushParser.new(parser)
|
||||||
block = lambda { |chunk, remaining, total| body << chunk }
|
params[:response_block] = lambda { |chunk, remaining, total| body << chunk }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,20 @@ module Fog
|
||||||
# ==== Parameters
|
# ==== Parameters
|
||||||
# * container<~String> - Name for container, should be < 256 bytes and must not contain '/'
|
# * container<~String> - Name for container, should be < 256 bytes and must not contain '/'
|
||||||
#
|
#
|
||||||
def put_object(container, object, data, options = {})
|
def put_object(container, object, data, options = {}, &block)
|
||||||
data = Fog::Storage.parse_data(data)
|
data = Fog::Storage.parse_data(data)
|
||||||
headers = data[:headers].merge!(options)
|
headers = data[:headers].merge!(options)
|
||||||
|
if block_given?
|
||||||
|
headers['Transfer-Encoding'] = 'chunked'
|
||||||
|
headers.delete('Content-Length')
|
||||||
|
return request(
|
||||||
|
:request_block => block,
|
||||||
|
:expects => 201,
|
||||||
|
:headers => headers,
|
||||||
|
:method => 'PUT',
|
||||||
|
:path => "#{Fog::HP.escape(container)}/#{Fog::HP.escape(object)}"
|
||||||
|
)
|
||||||
|
end
|
||||||
if headers.has_key?('Transfer-Encoding')
|
if headers.has_key?('Transfer-Encoding')
|
||||||
headers.delete('Content-Length')
|
headers.delete('Content-Length')
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue