rack/rack — pull request #639 by codekitchen (2014-01-06 23:28:53+00:00)
Title: allow overriding the rack multipart parser tempfile class

This allows for more flexibility in how to buffer (or stream) multipart file uploads, rather than always using Tempfile and buffering to local TMPDIR.

Also allow a custom buffering size, to optimize large file reads.

Our initial use case for this is to use it in combination with [Passenger's new PassengerBufferUpload](http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerBufferUpload) feature in order to allow a Rails action to stream multipart file uploads to S3 as they are being uploaded by the client, with absolutely no local copy stored at all.

Our initial solution was to make a custom `Request` subclass that duplicated the `Rack::Multipart::Parser` code just to change this single `Tempfile.new` line, but the functionality seems generally useful so I decided to do a pull request.

Let me know if using these `env` variables is the best way to pass this information to the parser, it seemed like the most flexible and least invasive solution.