class Rack::Multipart::Parser::Collector
def check_part_limits
def check_part_limits file_limit = Utils.multipart_file_limit part_limit = Utils.multipart_total_part_limit if file_limit && file_limit > 0 if @open_files >= file_limit @mime_parts.each(&:close) raise MultipartPartLimitError, 'Maximum file multiparts in content reached' end end if part_limit && part_limit > 0 if @mime_parts.size >= part_limit @mime_parts.each(&:close) raise MultipartTotalPartLimitError, 'Maximum total multiparts in content reached' end end end
def each
def each @mime_parts.each { |part| yield part } end
def initialize(tempfile)
def initialize(tempfile) @tempfile = tempfile @mime_parts = [] @open_files = 0 end
def on_mime_body(mime_index, content)
def on_mime_body(mime_index, content) @mime_parts[mime_index].body << content end
def on_mime_finish(mime_index)
def on_mime_finish(mime_index) end
def on_mime_head(mime_index, head, filename, content_type, name)
def on_mime_head(mime_index, head, filename, content_type, name) if filename body = @tempfile.call(filename, content_type) body.binmode if body.respond_to?(:binmode) klass = TempfilePart @open_files += 1 else body = String.new klass = BufferPart end @mime_parts[mime_index] = klass.new(body, head, filename, content_type, name) check_part_limits end