def file_from(request, key, value)
        # direct to rails...
        # ----->
        #   key: file,
        #   value: {
        #     :filename =>"file.mov",
        #     :type     =>"video/quicktime",
        #     :tempfile =>#<File:/var/folders/xn/x665dh2j6qx_t7w5bqcsfgcr0000gn/T/RackMultipart20120330-11052-1ysyd0c>,
        #     :name     =>"video[file]",
        #     :head     =>"Content-Disposition: form-data; name=\"video[file]\"; filename=\"file.mov\"\r\nContent-Type: video/quicktime\r\n"
        #   }

        # with nginx upload (configured per README)...
        # ----->
        #   key: file,
        #   value: {
        #     "filename"=>"file.mov",
        #     "type"    =>"video/quicktime",
        #     "tempfile"=>"/path/to/app/tmp/uploads/1/0000000001",
        #     "md5"     =>"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        #     "size"    =>"5242880000"
        #   }

        if value.is_a?(Hash)
          attributes = HashWithIndifferentAccess.new(value)
          tempfile   = attributes[:tempfile]

          if tempfile.present?
            # check for "chunked" upload
            if attributes[:filename] == 'blob'
              temppath = tempfile.is_a?(String) ? tempfile : tempfile.path
              storage  = ::File.expand_path(::File.join(temppath, '../../chunked'))
              uploader = request.params['uploader']
              combined = ::File.join(storage, uploader)
              fullsize = request.env['HTTP_X_FILE_SIZE'].to_i

              # append chunk to "combined" File
              FileUtils.mkdir_p(storage)
              ::File.open(combined, 'ab') do |f|
                f.write(::File.read(tempfile))
              end

              # finished?
              if ::File.size(combined) == fullsize
                attributes = {
                  :filename => request.env['HTTP_X_FILE_NAME'],
                  :size     => request.env['HTTP_X_FILE_SIZE'],
                  :type     => request.env['HTTP_X_FILE_TYPE'],
                  :tempfile => ::File.new(combined)
                }

                return Rack::LargeUploads::UploadedFile.new(attributes)
              else
                return Rack::LargeUploads::UploadedChunk.new(attributes)
              end
            else
              return Rack::LargeUploads::UploadedFile.new(attributes)
            end
          end
        end

        nil
      end
def file_from(request, key, value)
        # direct to rails...
        # ----->
        #   key: file,
        #   value: {
        #     :filename =>"file.mov",
        #     :type     =>"video/quicktime",
        #     :tempfile =>#<File:/var/folders/xn/x665dh2j6qx_t7w5bqcsfgcr0000gn/T/RackMultipart20120330-11052-1ysyd0c>,
        #     :name     =>"video[file]",
        #     :head     =>"Content-Disposition: form-data; name=\"video[file]\"; filename=\"file.mov\"\r\nContent-Type: video/quicktime\r\n"
        #   }

        # with nginx upload (configured per README)...
        # ----->
        #   key: file,
        #   value: {
        #     "filename"=>"file.mov",
        #     "type"    =>"video/quicktime",
        #     "tempfile"=>"/path/to/app/tmp/uploads/1/0000000001",
        #     "md5"     =>"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        #     "size"    =>"5242880000"
        #   }

        if value.is_a?(Hash)
          attributes = HashWithIndifferentAccess.new(value)
          tempfile   = attributes[:tempfile]

          if tempfile.present?
            # check for "chunked" upload
            if attributes[:filename] == 'blob'
              temppath = tempfile.is_a?(String) ? tempfile : tempfile.path
              storage  = ::File.expand_path(::File.join(temppath, '../../chunked'))
              uploader = request.params['uploader']
              combined = ::File.join(storage, uploader)
              fullsize = request.env['HTTP_X_FILE_SIZE'].to_i

              # append chunk to "combined" File
              FileUtils.mkdir_p(storage)
              ::File.open(combined, 'ab') do |f|
                f.write(::File.read(tempfile))
              end

              # finished?
              if ::File.size(combined) == fullsize
                attributes = {
                  :filename => request.env['HTTP_X_FILE_NAME'],
                  :size     => request.env['HTTP_X_FILE_SIZE'],
                  :type     => request.env['HTTP_X_FILE_TYPE'],
                  :tempfile => ::File.new(combined)
                }

                return Rack::LargeUploads::UploadedFile.new(attributes)
              else
                return Rack::LargeUploads::UploadedChunk.new(attributes)
              end
            else
              return Rack::LargeUploads::UploadedFile.new(attributes)
            end
          end
        end

        nil
      end
TODO:
   * make chunked check configurable (:filename value at least, maybe other)
   * make chunked storage path configurable
   * make 'uploader' param configurable, and per-upload rather than per-request