Welcome to mirror list, hosted at ThFree Co, Russian Federation.

file_streamer.rb « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4e3c6d3c773ac1238184e137316ed7bf79a218dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class FileStreamer #:nodoc:
  attr_reader :to_path

  def initialize(path)
    @to_path = path
  end

  # Stream the file's contents if Rack::Sendfile isn't present.
  def each
    File.open(to_path, 'rb') do |file|
      while chunk = file.read(16384)
        yield chunk
      end
    end
  end
end