Failure reading PNG files with Ruby on Windows
问题 I am creating a Zip file containing both text files and image files. The code works as expected when running on MacOS, but it fails when running on Windows because the image file contents are not read correctly. The snippet below always reads PNG image files as '‰PNG', adding a 5 bytes file in the Zip for each PNG image. Is it an issue regarding Windows environment? zip_fs.file.open(destination, 'w') do |f| f.write File.read(file_name) end 回答1: from Why are binary files corrupted when zipping