diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-11-19 15:46:04 +0100 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-11-19 15:46:04 +0100 |
commit | f5a630111fb1499a1541e77040529f74ca6475ec (patch) | |
tree | c3c82cd23d7bdcbfe4ec38d12be4572a6e8653ee /lib/file_streamer.rb | |
parent | 28af56dea5a88ffcaceb082cf67c9c1ab021609d (diff) | |
parent | c8074b6b115c95c68d5f7df300a391b4eab521d5 (diff) | |
download | gitlab-ce-f5a630111fb1499a1541e77040529f74ca6475ec.tar.gz |
Merge branch 'master' into reference-pipeline-and-caching
Diffstat (limited to 'lib/file_streamer.rb')
-rw-r--r-- | lib/file_streamer.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/file_streamer.rb b/lib/file_streamer.rb new file mode 100644 index 00000000000..4e3c6d3c773 --- /dev/null +++ b/lib/file_streamer.rb @@ -0,0 +1,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 |