From: David Heinemeier Hansson Date: 2003-11-03T03:03:51+09:00 Subject: CGI uses file size to distinguish between regular values and files I've been having a ton of problems handling file uploads with CGI.rb and after diving into the code, it looks like my woes can be narrowed down to these lines in the read_multipart method: if 10240 < content_length require "tempfile" body = Tempfile.new("CGI") else begin require "stringio" body = StringIO.new rescue LoadError require "tempfile" body = Tempfile.new("CGI") end end It sure looks like the sole differentiator on whether a request should be treated with StringIOs or Tempfiles is the size of the request. If this understanding is correct, I have no trouble understanding why I've been pulling out my hair in frustration the last couple or many hours. If I upload just one file that brings the content_length above 10240, ALL fields in the request is treated as Tempfiles. If I'm uploading a small file that keeps the content_length below 10240, all the fields -- including the file -- is treated as StringIOs. For starters, how would one move a small file, treated as StringIO, to another location? With Tempfile, you just do Tempfile#local_path, and move away. But it's not so straight forward with StringIO. It also seems very tedious that the application has to know whether the file upload was big or small and act accordingly. Maybe I'm just missing something. Like that StringIO and Tempfile is supposed to act the same and they just don't on my system for some reason. Or this is a bug. Since my last cries for help haven't been overly succesful, I gather that most consider CGI.rb to be a black box as well. So perhaps I should get in touch with the original author. Does anyone know if Wakou Aoyama is still actively maintaining CGI.rb? -- David Heinemeier Hansson. http://www.loudthinking.com/ -- Broadcasting Brain