The javax.servlet.http.Part interface lacks a method for retrieving the file name of a part. Most request parts have file names, typically provided by the client's browser as the name of the file on the client's file system when the file is uploaded through the form submission. Currently, consumers of Part must create their own method to extract the file name:
Tomcat, as an example, already has a method to extract the file name in its Part implementation, but since it is not exposed via the public Part interface developers cannot use it without limiting the portability of their applications. It's possible other containers already do something similar.
The suggested getFileName() method should:
- Locate the Content-Disposition header from the Part. If no such header exists, return null.
- Extract the filename attribute from the Content-Disposition header and return its value trimmed.
- If no filename attribute exists or the filename attribute value is null, return null.
- Not throw any exceptions.
Estimate 5 minutes to add the method to the interface and < 2 hours to add relevant documentation regarding the method to the spec.