diff options
author | Jeff Stubler <brunsa2@gmail.com> | 2015-11-12 09:05:29 -0600 |
---|---|---|
committer | Jeff Stubler <brunsa2@gmail.com> | 2015-11-12 09:05:29 -0600 |
commit | 64ca9cf3e4a56a19f09160a91c5433d2ddb632cf (patch) | |
tree | f114ab02adb4815058fe7b84a1527ac5ed7a597e /lib/file_streamer.rb | |
parent | e0c64fac68b4b3acc48300956146b85e03b426ce (diff) | |
parent | 12b35c6fe85073d809a764d24b51937f63b9d098 (diff) | |
download | gitlab-ce-64ca9cf3e4a56a19f09160a91c5433d2ddb632cf.tar.gz |
Merge branch 'master' into diverging-branch-graphs
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 |