You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Large plain/text files returned as gzip and library doesn't handle this case #19
>>> 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.
Activity