HTTP Download very Big File

Posted by Luca on Stack Overflow See other posts from Stack Overflow or by Luca
Published on 2009-10-08T15:43:00Z Indexed on 2010/05/07 9:38 UTC
Read the original article Hit count: 217

Filed under:
|
|
|

I'm working at a web application in Python/Twisted.

I want the user to be able to download a very big file (> 100 Mb). I don't want to load all the file in memory (of the server), of course.

server side I have this idea:

...
request.setHeader('Content-Type', 'text/plain')
fp = open(fileName, 'rb')
try:
    r = None
    while r != '':
        r = fp.read(1024)
        request.write(r)
finally:
    fp.close()
    request.finish()

I expected this to work, but I have problems: I'm testing with FF... It seems the browser make me wait until the file is completed downloaded, and then I have the open/save dialog box.

I expected the dialog box immediately, and then the progress bar in action...

Maybe I have to add something in the Http header... Something like the size of the file?

© Stack Overflow or respective owner

Related posts about http

Related posts about python