Odd behaviour with uploaded gzip file

11 views
Skip to first unread message

James Burke

unread,
Jun 16, 2016, 7:27:53 AM6/16/16
to web2py-users
Hi,

I was trying to parse the contents of a single gzipped file, but kept getting an empty file.

@auth.allows_jwt()
@request.restful()
def log():
   
def POST(*args,**vars):

       
with gzip.GzipFile(fileobj=request.vars.file.file, mode='rb') as f:
            test
= f.readlines()
           
print test
       
return dict()
   
return dict(POST=POST)




So i decided to print the contents of the file beforehand to make sure it wasn't empty.

print request.vars.file

with gzip.GzipFile(fileobj=request.vars.file.file, mode='rb') as f:
    test
= f.readlines()
   
print test

To my surprise it started outputting the the contents of the zipped file.

If I comment out the print statement it stops working... Any ideas what is causing this behaviour?


Cheers,

James
Reply all
Reply to author
Forward
0 new messages