Get file size from "Content-Length" value from a file in python 3.2 Get file size from "Content-Length" value from a file in python 3.2 python-3.x python-3.x

Get file size from "Content-Length" value from a file in python 3.2


It looks like you are using Python 3, and have read some code / documentation for Python 2.x. It is poorly documented, but there is no getheaders method in Python 3, but only a get_all method.

See this bug report.


for Content-Length:

file_size = int(d.getheader('Content-Length'))


Change final line to:

file_size = int(meta.get_all("Content-Length")[0])