From: John W Higgins Date: 2003-11-04T07:17:33+09:00 Subject: Re: CGI uses file size to distinguish between regular values and files The original response from Simon Kitching was the best on this topic. You are trying to access a private implementation object instead of the public object. It looks like all the CGI.rb API guarantees you is an IO object from which you can access the uploads. If the writer of the class wishes to use a regular file, or a tempfile, or StringIO or whatever other subclasses of the IO superclass that really is up to them. You are trying to "cheat" (couldn't think of a better word) by grabbing the tempfile instead of using the generic IO methods of read or write. Yes, there is no question that a tempfile is easier to use if you want to copy the data - however, I'm sure that from a performance standard - the author has decided that the overhead of a tempfile shouldn't be incurred by the average user when the length of the data is below the 10240 character threshold. It's like 99.9% of performance decisions made with something like this - it will never please everyone all the time - however, I think the author made a pretty good decision and I can't imagine it's that difficult to do a File.open(upload, 'w') {|f| f.write(file.read) } which would work under both circumstances. If you find that you performance suffers greatly by this then I would look to superclassing CGI and making the trivial modification required to force the use of Tempfiles. Ruby offers soooo many choices to do any particular task that we all have to realize that the authors of the various modules have to make decisions that they believe will meet our requirements. That said, it's so simple to make the changes that you need that I would spend my time superclassing CGI and moving onto better things. John W Higgins john@wishdev.com On Mon, 2003-11-03 at 12:58, Austin Ziegler wrote: > On Tue, 4 Nov 2003 04:44:50 +0900, Dmitry Borodaenko wrote: > [snip] > > Sort of. I want it to work that way in the default CGI library. There should > be no distinction for the user who just wants the data. I *still* want to be > able to access the resulting Tempfile, though, if I'm deciding to do > file-based storage instead of, say, database storage. That way, I don't need > to write the data, but can tell the OS to copy the file. > > -austin > -- > austin ziegler * austin@halostatue.ca * Toronto, ON, Canada > software designer * pragmatic programmer * 2003.11.03 > * 15.56.30 > > > > >