Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 331759 - [upload] Allow/disallow specific contentTypes to upload
Summary: [upload] Allow/disallow specific contentTypes to upload
Status: RESOLVED WONTFIX
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.4   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-03 08:23 EST by Benjamin Wolff CLA
Modified: 2011-10-10 18:02 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Wolff CLA 2010-12-03 08:23:33 EST
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?
Comment 1 Benjamin Wolff CLA 2010-12-03 08:37:19 EST
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
Comment 2 Ralf Sternberg CLA 2011-10-10 18:02:38 EDT
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.