>>> import shutil
>>> from smartfile import BasicClient
>>> api = BasicClient()
>>> f = api.get('/path/data/', 'small.txt')
>>> with open('small.txt', 'wb') as o:
>>> # f.getheaders().get('Content-Encoding')
>>> shutil.copyfileobj(f, o)
works fine with small files, but when file is large (I tested 100Mb text file)
f.getheaders().get('Content-Encoding') returns gzip and instead of expected source text file gzip content is downloaded and saved to file.
It can be handled with:
if f.getheaders().get('Content-Encoding') == 'gzip':
o.write(gzip.decompress(f.read()))
else:
shutil.copyfileobj(f, o)
but ideally I think library should handle this case.
Or, at least, docs have to be updated and mention this possible issue.
python --version Python 3.6.1
smartfile==2.19
Example from documentation:
works fine with small files, but when file is large (I tested 100Mb text file)
f.getheaders().get('Content-Encoding')
returnsgzip
and instead of expected source text file gzip content is downloaded and saved to file.It can be handled with:
but ideally I think library should handle this case. Or, at least, docs have to be updated and mention this possible issue.