Community
Participate
Working Groups
Similar to Upload#getConfiguration().setMaxFileSize() it should be possible to add a map that allows (and/or disallows) specific contentTypes. If the contentType is not on the whitelist/is on the blacklist, an exception should be thrown. This is useful to only allow image files or only disallow pdf files. The exception allows a unified handling of upload errors with the upload widget , like FileSizeExceededExpetion for example. I currently do this check in the application code after the upload. It would be more convenient to let the widget handle this case and just throw a proper exception. It may be even possible to throw this exception before the upload happens so there is no unnecessary traffic. I didn't find a way to do this in application code so far :(. What do you think?
I meant a set, not a map ;). API Ideas: IUploadConfiguration#setContentTypeFilter(Set<String> contentType, boolean allow) The set contains the RFC2616 types and the boolean tells if it is a blacklist or whitelist. The thrown Exception should be of type org.apache.commons.fileupload.FileUploadBase.InvalidContentTypeException
The upload widget is obsolete and will be removed in the future. Use the new FileUpload widget or the FileDialog implementation from the incubator instead. With the new server-side fileupload design, it is possible to implement a FileUploadReceiver that rejects certain file types by throwing an exception.