I don't know how Safari identifies a content-type for the file before it uploaded (extension or magic bit). But when it failed to identify it - nothing is passed to server
Example upload CSV file from Safari on Windows (the same is from the Mac)
4982 read(5, "POST /contacts;import_file HTTP/1.1\r\n Host: 127.0.0.1:4001\r\nAccept-Encoding: gzip, deflate\r\nAccept-Language: en\r\n User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/522.15.5 (KHTML, like Gecko) Version/3.0.3 Safari/522.15.5\r\nContent-Type: multipart/form-data; boundary=----WebKitFormBoundaryAABu3wAAGPgAAE5m\r\n Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n Cookie: _event_modules=mh-guest-list\r\n Content-Length: 2607\r\n\r\n------WebKitFormBoundaryAABu3wAAGPgAAE5m\r\n Content-Disposition: form-data; name=\"type\"\r\n\r\noutlook_csv\r\n ------WebKitFormBoundaryAABu3wAAGPgAAE5m\r\n Content-Disposition: form-data; name=\"file\"; filename=\"C:\\TMP\\outlook-csv-windows.csv\"\r\n\r\n \"Title\",\"First Name\",\"Middle Name\",\"Last Name\",\"Suffix\",\"Company\",\"Department\",\"Job Title\", \"Business Street\",\"Business Street 2\",\"Business Street 3\", \"Business City\",\"Business State\",\"Business Postal Code\",\"Business Country\", \"Home Street\",\"Home Street 2\",\"Home Street 3\",\"Home City\",\"Home State\", \"Home Postal Code\",\"Home Country\",\"Other Street\",\"Other Street 2\",\"Other Street 3\", \"Other City\",\"Other State\",\"Other Postal Code\",\"Other Country\",\"Assistant\'s Phone\", \"Business Fax\",\"Business Phone\",\"Business Phone 2\",\"Callback\",\"Car Phone\", \"Company Main Phone\",\"Home Fax\",\"Home Phone\",\"Home Phone 2\",\"ISDN\",\"Mobile Phone\", \"Other Fax\",\"Other Phone\",\"Pager\",\"Primary Phone\",\"Radio Phone\",\"TTY/TDD Phone\", \"Telex\",\"Account\",\"Anniversary\",\"Assistant\'s Name\",\"Billing Information\",\"Birthday\", \"Business Address PO Box\",\"Categories\",\"Children\",\"Directory Server\",\"E-mail Address\", \"E-mail Type\",\"E-mail Display Name\",\"E-mail 2 Address\",\"E-mail 2 Type\", \"E-mail 2 Display Name\",\"E-"..., 16384) = 3408
The same file from Firefox
24985 read(5, "POST /contacts;import_file HTTP/1.1\r\n Host: 127.0.0.1:4002\r\n User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.8) Gecko/20071008 Firefox/2.0.0.8\r\n Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n Accept-Language: en-us,en;q=0.5\r\n Accept-Encoding: gzip,deflate\r\n Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n Cookie: _event_modules=mh-guest-list\r\n Content-Type: multipart/form-data; boundary=---------------------------1603611221168\r\n Max-Forwards: 10\r\n Connection: Keep-Alive\r\n Content-Length: 2648\r\n\r\n-----------------------------1603611221168\r\n Content-Disposition: form-data; name=\"type\"\r\n\r\noutlook_csv\r\n -----------------------------1603611221168\r\n Content-Disposition: form-data; name=\"file\"; filename=\"outlook-csv-windows.csv\"\r\n Content-Type: application/octet-stream\r\n\r\n\ "Title\",\"First Name\",\"Middle Name\",\"Last Name\",\"Suffix\",\"Company\",\"Department\", \"Job Title\",\"Business Street\",\"Business Street 2\",\"Business Street 3\", \"Business City\",\"Business State\",\"Business Postal Code\",\"Business Country\", \"Home Street\",\"Home Street 2\",\"Home Street 3\",\"Home City\",\"Home State\", \"Home Postal Code\",\"Home Country\",\"Other Street\",\"Other Street 2\",\"Other Street 3\", \"Other City\",\"Other State\",\"Other Postal Code\",\"Other Country\",\"Assistant\'s Phone\", \"Business Fax\",\"Business Phone\",\"Business Phone 2\",\"Callback\",\"Car Phone\", \"Company Main Phone\",\"Home Fax\",\"Home Phone\",\"Home Phone 2\",\"ISDN\",\"Mobile Phone\", \"Other Fax\",\"Other Phone\",\"Pager\",\"Primary Phone\",\"Radio Phone\",\"TTY/TDD Phone\", \"Telex\",\"Account\",\"Anniversary\",\"Assistant\'s Name\",\"Billing Information\",\"Birthday\", \"Business Address PO Box\",\"Categories\",\"Children\",\"Directory Server\",\"E-mail Address\", \"E-mail Type\",\"E-mail Dis"..., 16384) = 3485
As a result params[:file] doesn't contain Tempfile or StringIO as you would expect inside your controllers, but the actual file content. And an attempt to call read on it - raises an Exception.
This "The Bear and the Gardener" type of request processing happening inside vendor/rails/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb method get_typed_value
--> #0 ./script/../config/../vendor/rails/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb:76 in 'get_typed_value'
#1 ./script/../config/../vendor/rails/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb:34 in '[]'
#2 ./script/../config/../vendor/rails/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb:28 in 'parse_request_parameters'
#3 ./script/../config/../vendor/rails/actionpack/lib/action_controller/cgi_process.rb:73 in 'request_parameters'
#4 ./script/../config/../vendor/rails/actionpack/lib/action_controller/request.rb:13 in 'parameters'
#5 ./script/../config/../vendor/rails/actionpack/lib/action_controller/request.rb:20 in 'method'
Found on Rails 1.2.3. It would be much better not to do such type of assumptions in a core code.