Parsing form-data multiparts

If you ever needed to parse form-based multipart data, you are probably aware of the Jakarta Commons FileUpload library. But while this library is primarily intended to parse data directly from HttpRequest objects and thus handle uploading of files in your web application, it could be used to parse an arbitrary InputStream and extract multiparts from it too.

As you can probably guess, the part of the library that is related to handling file uploads is well documented, but for the low-level API you can only find the broken example in the JavaDocs. I know that this funcionality is rarely needed, but still it deserves a working example, so here it is.

Continue reading on onJava

Leave a comment

Your email address will not be published. Required fields are marked *