Skip to main content
Version: 3.14.x.x LTS

Multipart

MethodDescriptionSample
Multipart:new"). If you do not set this parameter, the system will use the default "8192". The size must be at least twice as big as the size of the multipart you are interested in. All parts bigger then half of this size will not be "seen".Multipart = require "Multipart"local contentTypeHeader = req:getHeader("Content-Type")local multipartParser = Multipart:new(contentTypeHeader)
Multipart:getBoundary()Returns the boundary of the multipart request.local boundary = multipartParser:getBoundary()
Multipart:registerFormDataFunction(myFunction)Allows you to register a custom function. The method which is defined as "myFunction" will be called for each part of this multipart-request. With the custom method tracing, content rewriting or even part removing is possible.function traceParts(name, value) tracer:debug("PartName is: " .. name .. " value of part: " .. value)endmultipartParser:registerFormDataFunction(traceParts)
Multipart:stream(chunk)Will call the windowed processor with the given chunk, so that the registered function will be called for each part of this multipart-request. This method call should go into the input stream hook.function processRequest(req, resp, chunk) local ret = chunk if isMultipartFormDataReq then ret = multipartParser:stream(chunk) end return retend

For a complete example, see the configuration in the chapter.