Sha256: 5a8547008d7cfbfec22999dede15fe2783b9f49da53cad6ddc5babfd57f3b0e9
Contents?: true
Size: 852 Bytes
Versions: 4
Compression:
Stored size: 852 Bytes
Contents
# frozen_string_literal: true # Should be included into a Rails controller (together with `ActionController::Live`) # for easy ZIP output from any action. module ZipTricks::RailsStreaming # Opens a {ZipTricks::Streamer} and yields it to the caller. The output of the streamer # gets automatically forwarded to the Rails response stream. When the output completes, # the Rails response stream is going to be closed automatically. # @yield [Streamer] the streamer that can be written to def zip_tricks_stream response.headers['Content-Type'] = 'application/zip' # Create a wrapper for the write call that quacks like something you # can << to, used by ZipTricks w = ZipTricks::BlockWrite.new { |chunk| response.stream.write(chunk) } ZipTricks::Streamer.open(w) { |z| yield(z) } ensure response.stream.close end end
Version data entries
4 entries across 4 versions & 1 rubygems