From: Brent W. <bre...@in...> - 2001-01-27 02:08:20
|
I'm pretty sure you don't want to do file upload in a .tml file, and it is also true that the ncgi:: package is not at all efficient because it loads the whole thing into memory. It sounds like we need a special domain handler that is designed and optimized for multipart uploads. It would, for example, automatically create the files in an upload area, and then set up some context that has the rest of the meta data, then call a handler routine (or .tml file, or something). I'd love to see something like that for TclHttpd - I can't guarantee how soon I'll get inspired to hack something up though. You might drop back to cgi.tcl in the meantime. >>>"MENGES,JOHN E (HP-Corvallis,ex1)" said: > Brent - I did some more investigation on this yesterday. Tcl-httpd is readi ng > the POST data in binary (actually lf) mode, but the ncgi package (from tclli b > 0.8) is doing a wholesale translation of <crlf> to <lf> in ncgi::multipart ( the > following lines): > > # The query data is typically read in binary mode, which preserves > # the \r\n sequence from a Windows-based browser. > if {[regexp -- $boundary\r\n $query]} { > regsub -all \r\n $query \n query > } > > Seems like it should not be doing this translation on the file content. I'v e > manually extracted the file from $query before this regsub is executed, and it's > all correct to that point. > > My form looks like this, in a .tml file: > > <form name="Form" method="post" enctype="multipart/form-data" action=""> > <input name="file" type="file"> > <input type="submit"> > </form> > > and in the .tml file that is the target of the action (the same .tml file in > this case), I access the file content with: > > set File [open {SomeFile} w] > fconfigure $File -translation {binary binary} > puts $File [ncgi::value file] > close $File > > A sample file I tried to upload has content "Line1<cr><lf>Line2". It ends u p as > "Line1<lf>Line2". > > I tried commenting out the <crlf> to <lf> translation above, but ncgi::multi part > seems to rely on this translation for other parts of the query. > > I have a couple of workarounds in mind. One option is to grab the query dat a > before it is destroyed and parse it myself. Another is to drop out to Don > Libes' cgi-tcl. There's another problem with tclhttpd's upload that is caus ing > me to consider the latter approach - the file upload times are too long. I' m > getting about 30 seconds per megabyte, while other web servers are giving us > about 3 seconds per megabyte on upload. A co-worker searched the web and fo und > a claim that cgi-tcl fixed both the binary file upload and performance probl ems. > So I'm going to look at that today as an alternative. > > Other than these problems with file upload, tclhttpd has been working fine f or > our project. > > > > -----Original Message----- > From: Brent Welch [mailto:bre...@in...] > Sent: Thursday, January 25, 2001 10:56 PM > To: MENGES,JOHN E (HP-Corvallis,ex1) > Cc: 'bre...@sc...' > Subject: Re: tclhttpd binary file upload > > > Can you be more specific about how you are doing the upload? > TclHttpd is pretty good about reading POST data in > binary mode. > > > >>>"MENGES,JOHN E (HP-Corvallis,ex1)" said: > > Brent - binary file upload using tclhttpd doesn't seem to work, > on windows > > (Win2k, to be exact). It looks like it's doing some sort of en > d-of-line > > translation. Is this a known problem? Is there a work-around? > > -- Brent Welch <bre...@in...> > http://www.interwoven.com -- Brent Welch <bre...@in...> http://www.interwoven.com |