Each time when you call:
the contents of AcceptMime.properties is loaded.
The keys in this property file is the mime-types (Content-Type), and their corresponding values are yes or no.
And the above method returns the Set object, which includes the mime-types whose values are yes.
You can pass this Set object to some methods of MimeParser.
Then, only the files of the specific mime-types can be uploaded.
In case of the invalid mime-types, MimeParser will throw InvalidContentTypeException.
For example, your JSP/Servlet may want to accept JEPG, PNG and GIF files only.
In this case, your AcceptMime.properties should have the lines like:
When your JSP/Servlet calls:
the returned Set object includes
Then, your JSP/Servlet can pass this Set object to some methods of MimeParser.
The source code of your JSP/Servlet will look like this:
Set accept_mime=AcceptMime.getAcceptMime(); // The uploaded file will be saved under the "foo" // sub-directory... String user="foo"; // The maximum file size is set to // 30*1024 bytes (30 KB), which can // override the "max_file" property. mime.parseAndSave(request,user,30*1024,accept_mime); |
Your JSP/Servlet will accept JPEG, PNG or GIF files, but will refuse other types of files.
Please place this property file under: