commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philipp Höfler <>
Subject [fileupload] Parse Multipart
Date Tue, 03 Jul 2018 14:41:11 GMT

I am using the commons.fileupload library to parse a multipart request.
public void post(@Context HttpServletRequest request) throws Exception
    List<FileItem> multiParts = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request);

    for(FileItem part : multiParts)
            System.out.printf("File %s, %s, %d%n", part.getName(),
                part.getContentType(), part.getSize());

The method is part of a small osgi based app, that utilizes the HttpWhiteboard to implement
a REST service.
The shown code is working.

Unfortunately, this is called by a quite old system, that does not provide a name field for
each part.
The library ignores all parts, that does not have a name.

Is there any easy solution, how to avoid ignoring the unnamed parts?
Is it possible the set a random name if it does not exist?

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message