1
0
Fork 0
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:
Terry Howe 2012-06-18 08:16:54 -06:00 committed by Rupak Ganguly
parent 275e9599ae
commit dab0fcc33f
2 changed files with 13 additions and 2 deletions

View file

@ -13,7 +13,7 @@ module Fog
unless block_given?
if (parser = params.delete(: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

View file

@ -8,9 +8,20 @@ module Fog
# ==== Parameters
# * 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)
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')
headers.delete('Content-Length')
end