Unexpected EOF while inflating GZIP file?

C

cmercier

Hi,

I'm trying to inflate a gzip file but for whatever reason, it always
gives me the error "unexpected end of file". I tried with 3 different
..gz file and I always get the same result. Can anyone help please?

Thanks!


Here's my code:

----
require 'zlib'

zip_file ='tmp_downloads/edu.zone.gz'
output_path = 'tmp_downloads/tmp/'

f = File.open(zip_file)
gz = Zlib::GzipReader.new(f)

print gz.read

gz.close

----

and the error

test.rb:9:in `read': unexpected end of file (Zlib::GzipFile::Error)
from test.rb:9
 
R

Robert Klemme

Hi,

I'm trying to inflate a gzip file but for whatever reason, it always
gives me the error "unexpected end of file". I tried with 3 different
.gz file and I always get the same result. Can anyone help please?

Did you verify (with the command line tool) that the file is actually ok?

Kind regards

robert
 
C

cmercier

I downloaded the file from Verisign, and the md5sum is ok. I can
extract it with Winrar...

I'll try with the internic file.
 
C

cmercier

I'm getting the exact same error with the file from Internic.net. I'm
on a Windows box, could it be why?
 
K

Karl von Laudermann

Hi,

I'm trying to inflate a gzip file but for whatever reason, it always
gives me the error "unexpected end of file". I tried with 3 different
.gz file and I always get the same result. Can anyone help please?

f = File.open(zip_file)

You probably need to open the file in binary mode, i.e.:

f = File.open(zip_file, "rb")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,733
Latest member
LonaMonzon

Latest Threads

Top