Package au.id.villar.web.mfd
Class MultipartProcessor
java.lang.Object
au.id.villar.web.mfd.MultipartProcessor
Utility class to read a multipart body from and HTTP request.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringextractBoundary(String contentTypeValue) Extracts the boundary value from a Content-Type value.static voidprocess(String boundary, InputStream input, MultipartProcessorListener listener) Runs the process of reading multipart body.
-
Method Details
-
process
public static void process(String boundary, InputStream input, MultipartProcessorListener listener) throws IOException Runs the process of reading multipart body. For each part in the multipart request, the provided listener will be called.- Parameters:
boundary- The boundary field as specified in the Content-Type header.input- TheInputStreamrepresenting the http body.listener- TheMultipartProcessorListenerto be invoked on each part.- Throws:
IOException- If the providedInputStreamthrows this exception, or if it is detected that the body is not actually multipart type.
-
extractBoundary
Extracts the boundary value from a Content-Type value.- Parameters:
contentTypeValue- the value of a content-type header, of type multipart.- Returns:
- The boundary value, or
nullif it was not found
-