Downloading file with Python results in only 4.1kB

Posted by Vlad Ogay on Stack Overflow See other posts from Stack Overflow or by Vlad Ogay
Published on 2012-12-16T17:01:44Z Indexed on 2012/12/16 17:02 UTC
Read the original article Hit count: 274

Filed under:
|

I'm using simple code:

import urllib2
response = urllib2.urlopen("http://www.mysite.com/getfile/4355")
output = open('myfile.zip','wb')
output.write(response.read())
output.close()

The web-server is IIS + ASP.NET MVC 4 It returns FileResult wrapping a zip-file with "application/octet-stream" content-type.

The problem is that downloaded zip file is broken - only 4.1kB size, where it must be 24kB. When I type the url adress in web-browser directly - it downloads and opens fine.

Could you please, suggest, what's wrong with my Python code?

© Stack Overflow or respective owner

Related posts about python

Related posts about asp.net-mvc