On Mon, 3 Nov 2003 20:12:06 +0900, Dmitry Borodaenko wrote:
> On Mon, Nov 03, 2003 at 02:29:08PM +0900, Simon Kitching wrote:
>> I suspect that the fact that tempfiles are used by this module is a
>> private implementation detail, ie something that users are not supposed
>> to be aware of, or depend upon.
> Why, you can always check if the parameter you've got _is_ a Tempfile,
> and, if it is not, assume that it is small enough to be handled in core.
> 
> Adopted from Samizdat source:

> if Tempfile === file then
>   File.syscopy(file.path, upload)
> else   # StringIO
>   File.open(upload, 'w') {|f| f.write(file.read) }
> end

> Did I miss something?

Why should I have to make that distinction in *my* code? I've got a Perl app 
that I plan to port over to Ruby at some point, and it allows file uploads 
(up to a couple megabytes in size). Indeed, the way that I deal with the 
file uploads never touches the filesystem from the perspective of my 
application (the file "string" goes directly into a MySQL database). If I 
have to step into my own filehandling, then I may not port this app to Ruby 
even though it's a fine candidate for it otherwise.

The library should provide me the raw data. If I decide something is a file 
and want to take some shortcuts with it, then the library can provide me 
additional information (e.g., CGI.tempfile?(parameter_index)) and 
functionality to access that implementation detail, but I should never 
*have* to make the distinction in my application code. Ever.

-austin
--
austin ziegler    * austin / halostatue.ca * Toronto, ON, Canada
software designer * pragmatic programmer * 2003.11.03
                                         * 09.35.55