[Twisted-web] Problems uploading data in web2

Henrik Thostrup Jensen thostrup at gmail.com
Mon Feb 6 03:52:06 MST 2006


Hi

I'm trying to use web2 to stream uploading of data, but I ran into some
problems. First I tried building from the example in
http://twistedmatrix.com/projects/web2/documentation/examples/demo.html,
however args and files objects in the request did not show anything.
However the length of stream was correct, and using tcpdump, showed the
correct value. So I tried building my own uploader which look like this:

class Uploader(resource.PostableResource):
    def http_POST(self, ctx):
        request = iweb.IRequest(ctx)
        self.parse_stream(request.stream)

    @defer.deferredGenerator
    def parse_stream(self, stream):
        from twisted.web2 import fileupload
        s = fileupload.parse_urlencoded_stream(stream)
        while True:
            datas = s.read()
            datas = fileupload.wait(datas)
            yield datas
            datas = datas.getResult()

Using the 0.1.0 release of web2 didn't get past the yield line. Using latest
from subversion (revision 15836), got past, but datas was None, even though
data had been send. I've used both cURL (using the -d switch) and wget
(using the --post-file switch) for uploading data, so I do not think the
client as malfunctioning. What am I doing wrong?

I'm aware that web2 is under development and all that, but I need streaming
upload, so the web module is not an option.

--
   - Henrik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-web/attachments/20060206/345e04b9/attachment.htm


More information about the Twisted-web mailing list