Module: Xporter::FileStreamer

Extended by:
ActiveSupport::Concern
Defined in:
lib/xporter/file_streamer.rb

Instance Method Summary collapse

Instance Method Details

#stream_file(filename, extension, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/xporter/file_streamer.rb', line 9

def stream_file(filename, extension, &block)
  response.headers["Content-Type"] = "application/octet-stream"
  response.headers["Content-Disposition"] = "attachment; filename=#{filename}.#{extension}"

  begin
    yield response.stream
  ensure
    response.stream.close
  end
end