summaryrefslogtreecommitdiff
path: root/lib/file_streamer.rb
diff options
context:
space:
mode:
authorJeff Stubler <brunsa2@gmail.com>2015-11-12 09:05:29 -0600
committerJeff Stubler <brunsa2@gmail.com>2015-11-12 09:05:29 -0600
commit64ca9cf3e4a56a19f09160a91c5433d2ddb632cf (patch)
treef114ab02adb4815058fe7b84a1527ac5ed7a597e /lib/file_streamer.rb
parente0c64fac68b4b3acc48300956146b85e03b426ce (diff)
parent12b35c6fe85073d809a764d24b51937f63b9d098 (diff)
downloadgitlab-ce-64ca9cf3e4a56a19f09160a91c5433d2ddb632cf.tar.gz
Merge branch 'master' into diverging-branch-graphs
Diffstat (limited to 'lib/file_streamer.rb')
-rw-r--r--lib/file_streamer.rb16
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