I would like to suggest Rails returns only FileTemp, because the
optimization with StringIO may cause to the programmer enter bugs in
your implementation by not knowing what type of return receive. 
I know that he can take a test to fix this type of problem:

  If upload_file.instance_of? (Tempfile) # Treat as TempFile else
StringIO

If this test should be the solution rather than modify the rails I
believe this kind of behavior should be documented, otherwise you can
take things like I will guess always receive FileTemp, which is not
true.

        
I looked at Rails code and it is easy to do this improvement. What do
you think about it?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Index: actionpack/lib/action_controller/request.rb
===================================================================
--- actionpack/lib/action_controller/request.rb	(revision 8041)
+++ actionpack/lib/action_controller/request.rb	(working copy)
@@ -1,4 +1,4 @@
-require 'tempfile'
+  require 'tempfile'
 require 'stringio'
 require 'strscan'
 
@@ -502,12 +502,7 @@
 
           loop do
             head = nil
-            content =
-              if 10240 < content_length
-                UploadedTempfile.new("CGI")
-              else
-                UploadedStringIO.new
-              end
+            content = UploadedTempfile.new("CGI")
             content.binmode if defined? content.binmode
 
             until head and /#{quoted_boundary}(?:#{EOL}|--)/n.match(buf)
@@ -699,11 +694,7 @@
       @original_filename
     end
   end
-
-  class UploadedStringIO < StringIO
-    include UploadedFile
-  end
-
+  
   class UploadedTempfile < Tempfile
     include UploadedFile
   end

Reply via email to