[Twisted-web] large file upload in web2 (was Re: http.HTTPFactory(site) equivalent in web2.0.2?)

Lenny G Arbage alengarbage at yahoo.com
Tue Jun 27 15:48:58 CDT 2006


David Reid wrote:
> Ok, while True is bad and blocking.  I
> think you should look at
> twisted.web2.static.FileSaver, if it
> doesn' perform a function close enough
> to what you want it is a good example
> of the right way to handle uploaded
> files as far as reading. (Hint it's to
> use things in the twisted.web2.stream
> library)  I expect your problems will
> go away

  Thanks for pointing this out.  The stream classes
look really cool.

  So I replaced my bad 'while True' blocking code with
the following:

        filestream = stream.FileStream(file)
        dest = os.path.join(SAVEDIR,filename)
        destfile = os.fdopen(os.open(dest,
            os.O_WRONLY | os.O_CREAT | os.O_EXCL,
            0644), 'w', 0)
        stream.readIntoFile(filestream, destfile)

  And this works great -- but only for files smaller
than 10M.  It looks like files >10M still produce the
hang -- same behavior as before.


> but you might still want to
> file a documentation enhancement bug
> stating that how to do this kind of
> thing is completely undocumented.

  I'll file tickets for both of these, to try to stop
cluttering the mailing list with these issues.

Thanks,
Lenny

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Twisted-web mailing list