Sha256: c7b80f35f2bfe10852194e23e80eb16d7e6d7151c7a63517f1c10af2834312a0

Contents?: true

Size: 461 Bytes

Versions: 2

Compression:

Stored size: 461 Bytes

Contents

module Xporter
  module FileStreamer
    extend ActiveSupport::Concern

    included do
      include ActionController::Live
    end

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
xporter-0.2.0 lib/xporter/file_streamer.rb
xporter-0.1.0 lib/xporter/file_streamer.rb