debian-mirror-gitlab/lib/file_streamer.rb
2015-11-26 14:37:03 +05:30

16 lines
301 B
Ruby

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