README.md in zip_tricks-4.7.3 vs README.md in zip_tricks-4.7.4

- old
+ new

@@ -28,11 +28,11 @@ ```ruby class ZipsController < ActionController::Base include ActionController::Live # required for streaming include ZipTricks::RailsStreaming - + def download zip_tricks_stream do |zip| zip.write_deflated_file('report1.csv') do |sink| CSV(sink) do |csv_write| csv << Person.column_names @@ -120,14 +120,14 @@ # io has to be an object that supports #<< ZipTricks::Streamer.open(io) do | zip | # raw_file is written "as is" (STORED mode). # Write the local file header first.. zip.add_stored_entry(filename: "first-file.bin", size: raw_file.size, crc32: raw_file_crc32) - + # then send the actual file contents bypassing the Streamer interface io.sendfile(my_temp_file) - + # ...and then adjust the ZIP offsets within the Streamer zip.simulate_write(my_temp_file.size) end ``` @@ -141,28 +141,34 @@ `BlockCRC32` computes the CRC32 checksum of an IO in a streaming fashion. It is slightly more convenient for the purpose than using the raw Zlib library functions. ```ruby crc = ZipTricks::StreamCRC32.new -crc << large_file.read(1024 * 12) until large_file.eof? +crc << next_chunk_of_data ... crc.to_i # Returns the actual CRC32 value computed so far ... # Append a known CRC32 value that has been computed previosuly crc.append(precomputed_crc32, size_of_the_blob_computed_from) ``` +You can also compute the CRC32 for an entire IO object if it responds to `#eof?`: + +```ruby +crc = ZipTricks::StreamCRC32.from_io(file) # Returns an Integer +``` + ## Reading ZIP files The library contains a reader module, play with it to see what is possible. It is not a complete ZIP reader but it was designed for a specific purpose (highly-parallel unpacking of remotely stored ZIP files), and as such it performs it's function quite well. Please beware of the security implications of using ZIP readers that have not been formally verified (ours hasn't been). ## Contributing to zip_tricks - + * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet. * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it. * Fork the project. * Start a feature/bugfix branch. * Commit and push until you are happy with your contribution. @@ -170,6 +176,6 @@ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it. * If you alter the `ZipWriter`, please take the time to run the test in the `qa/` directory. Ensure that the generated (large) files open manually - see README_QA for more. ## Copyright -Copyright (c) 2016 WeTransfer. See LICENSE.txt for further details. +Copyright (c) 2019 WeTransfer. See LICENSE.txt for further details.