lib/openstack/swift/storage_object.rb
def data_stream(size = -1, offset = 0, &block)
      headers = {'content-type'=>'application/json'}
      if size.to_i > 0
        range = sprintf("bytes=%d-%d", offset.to_i, (offset.to_i + size.to_i) - 1)
        headers['Range'] = range
      end
      server = @container.swift.connection.service_host
      path = @container.swift.connection.service_path + URI.encode("/#{@containername}/#{@name}")
      port = @container.swift.connection.service_port
      scheme = @container.swift.connection.service_scheme
      response = @container.swift.connection.csreq("GET", server, path, port, scheme, headers, nil, 0, &block)
      raise OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
      response
    end
# Retrieves the data from an object and returns a stream that must be passed to a block.
# Throws a OpenStack::Exception::ItemNotFound if the object doesn't exist.
#
# If the optional size and range arguments are provided, the call will return the number of bytes provided by
# size, starting from the offset provided in offset.
#
# The method returns the HTTP response object
#
#   data = ""
#   object.data_stream do |chunk| data += chunk end
#   => #<Net::HTTPOK 200 OK readbody=true>
#   data
#   => "This is the text stored in the file"
Retrieves the data from an object and returns a stream that must be passed to a block.
Throws a OpenStack::Exception::ItemNotFound if the object doesn't exist.

If the optional size and range arguments are provided, the call will return the number of bytes provided by
size, starting from the offset provided in offset.

The method returns the HTTP response object

data = ""
object.data_stream do |chunk| data += chunk end
> #
data
> "This is the text stored in the file"
Retrieves the data from an object and returns a stream that must be passed to a block . Throws a OpenStack :: Exception :: ItemNotFound if the object doesn ' t exist . If the optional size and range arguments are provided the call will return the number of bytes provided by size starting from the offset provided in offset . The method returns the HTTP response object data = " " object . data_stream do |chunk| data + = chunk end > # data > " This is the text stored in the file "
def data_stream(size = -1, offset = 0, &block)
      headers = {'content-type'=>'application/json'}
      if size.to_i > 0
        range = sprintf("bytes=%d-%d", offset.to_i, (offset.to_i + size.to_i) - 1)
        headers['Range'] = range
      end
      server = @container.swift.connection.service_host
      path = @container.swift.connection.service_path + URI.encode("/#{@containername}/#{@name}")
      port = @container.swift.connection.service_port
      scheme = @container.swift.connection.service_scheme
      response = @container.swift.connection.csreq("GET", server, path, port, scheme, headers, nil, 0, &block)
      raise OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
      response
    end
def data_stream ( size = - 1 , offset = 0 , & block ) headers = { 'content-type' => 'application/json' } if size . to_i > 0 range = sprintf ( "bytes=%d-%d" , offset . to_i , ( offset . to_i + size . to_i ) - 1 ) headers [ 'Range' ] = range end server = @container . swift . connection . service_host path = @container . swift . connection . service_path + URI . encode ( "/#{@containername}/#{@name}" ) port = @container . swift . connection . service_port scheme = @container . swift . connection . service_scheme response = @container . swift . connection . csreq ( "GET" , server , path , port , scheme , headers , nil , 0 , & block ) raise OpenStack :: Exception . raise_exception ( response ) unless response . code . match ( / ^20.$ / ) response end
Retrieves the data from an object and returns a stream that must be passed to a block.
Retrieves the data from an object and returns a stream that must be passed to a block .
size
offset
block