I’m using rubyzip library for zipping files.
But I encounter problems.
I try:
Zip::ZipOutputStream.open('c:/sites/efiling2/test.zip') do |zos|
zos.put_next_entry("test.rtf")
zos.write IO.read('c:/sites/efiling2/test.rtf')
zos.put_next_entry("test.jpg")
zos.write IO.read('c:/sites/efiling2/test.jpg')
end
But write method restricts a size of original files. For example my source file test.jpg has a size of 11913 bytes, but in archive there is a file test.jpg with size 11551 bytes. With test.rtf there is the same situations.
Any suggestions?
I suspect your problem may be
IO.read(). I’m not so sure it does binary data properly.I would try this instead and see if it fixes the problem: