Method: EventMachine::Connection#stream_file_data

Defined in:
lib/em/connection.rb

#stream_file_data(filename, args = {}) ⇒ EventMachine::Deferrable

Open a file on the filesystem and send it to the remote peer. This returns an object of type Deferrable. The object’s callbacks will be executed on the reactor main thread when the file has been completely scheduled for transmission to the remote peer. Its errbacks will be called in case of an error (such as file-not-found). This method employs various strategies to achieve the fastest possible performance, balanced against minimum consumption of memory.

Warning: this feature has an implicit dependency on an outboard extension, evma_fastfilereader. You must install this extension in order to use #stream_file_data with files larger than a certain size (currently 8192 bytes).

Parameters:

  • filename (String)

    Local path of the file to stream

  • args (Hash) (defaults to: {})

    Options

Options Hash (args):

  • :http_chunks (Boolean) — default: false

    If true, this method will stream the file data in a format compatible with the HTTP chunked-transfer encoding

Returns:



721
722
723
# File 'lib/em/connection.rb', line 721

def stream_file_data filename, args={}
  EventMachine::FileStreamer.new( self, filename, args )
end