1

I am downloading a file using HTTP Get request. When doing this on the browser, it takes few seconds for a file to generate and the response header contains: Content-Disposition: inline;filename="file.zip"

My python code downloads the file using:

response = opener.open(api_url,timeout=20)
content = response.read()
with open("file.zip","w") as fp:
    fp.write(content)

However the file.zip I have locally ends up being a corrupted file. Am I missing something?

  • http://stackoverflow.com/questions/22676/how-do-i-download-a-file-over-http-using-python – mounaim May 22 '15 at 22:40
  • Thanks for your comment. However I don't have URL for a filename. I generate a http get request which results in API returning a file for download. File size of the file I write to the disk is smaller than the actual file which makes me wonder if I need to handle this in some different way. – user1775775 May 24 '15 at 01:07

0 Answers0