Plupload wrapper for Vaadin 7.x
Plupload library integration add-on for Vaadin Framework 7.x
Pluploader is the most powerful client-side upload library out there and it would be a shame, if the Vaadin community couldn't use it.
The license concernes olny the addon. If You want to use Plupload, please familiarize youself with it's licensing terms.
Why is this add-on worthy of Your interest?
- Live upload progress updates without any needs of Push dependencies or enabled asyncSupported feature (no polling either).
- Chunked uploads with direct streaming to the desired destination - meaning that You can upload gigabyte-sized files without worrying about memory (RAM) usage on the server part, and if something goes wrong with the network the uploader will try to send the chunk again. You can also pause the upload and resume it, when network problems are resolved.
- Many events and event handlers give You the ability to respond dynamically to almost every situation
- 3 different compontents with 3 different purposes and complexity levels - choose the right one and customize it to Your needs
How is all this possible? The Plupload library (on the client side) controls the upload process and sends appropriate events, which are propagated to the server side through RPC. The server side can respond accordingly and control the upload process this way, or update the UI components. All the chunking and resizing (in case of images) is done on the client side. All server side has to do is implement some event handlers.
About the Browser compatibility: I've selected only the browsers, that I've tested this addon on, but there is a pretty good chance, that it will work on the others too...
This is a fairly new code and it's not properly polished yet, so there is a serious possibility that something can go wrong somewhere. Don't get angry, just submit an issue, or work on the problem and submit a pull request.
The Addon doesn't currently work with Portlets. If anybody would like to submit PR for that, feel free to do it :)
Sample code
final Plupload uploader = new Plupload("Browse", FontAwesome.FILES_O); final Label info = new Label(); uploader.setMaxFileSize("5mb"); //show notification after file is uploaded uploader.addFileUploadedListener(new Plupload.FileUploadedListener() { @Override public void onFileUploaded(PluploadFile file) { Notification.show("I've just uploaded file: " + file.getName()); } }); //update upload progress uploader.addUploadProgressListener(new Plupload.UploadProgressListener() { @Override public void onUploadProgress(PluploadFile file) { info.setValue("I'm uploading "+file.getName() +"and I'm at "+file.getPercent()+"%"); } }); //autostart the uploader after addind files uploader.addFilesAddedListener(new Plupload.FilesAddedListener() { @Override public void onFilesAdded(PluploadFile[] files) { uploader.start(); } }); //notify, when the upload process is completed uploader.addUploadCompleteListener(new Plupload.UploadCompleteListener() { @Override public void onUploadComplete() { info.setValue("upload is completed!"); } }); //handle errors uploader.addErrorListener(new Plupload.ErrorListener() { @Override public void onError(PluploadError error) { Notification.show("There was an error: " + error.getMessage(), Notification.Type.ERROR_MESSAGE); } });
PluploadManager manager = new PluploadManager(); manager.getUploader().setMaxFileSize("5mb"); manager.getUploader().addFileUploadedListener(new Plupload.FileUploadedListener() { @Override public void onFileUploaded(PluploadFile file) { Notification.show("I've just uploaded file: " + file.getName()); } }); //handle errors manager.getUploader().addErrorListener(new Plupload.ErrorListener() { @Override public void onError(PluploadError error) { Notification.show("There was an error: " + error.getMessage(), Notification.Type.ERROR_MESSAGE); } });
final PluploadField<File> field = new PluploadField(File.class); field.getUploader().setMaxFileSize("5mb"); //field value is an instance of java.io.File field.getUploader().addFileUploadedListener(new Plupload.FileUploadedListener() { @Override public void onFileUploaded(PluploadFile file) { Notification.show("I've just uploaded file: " + file.getName() + "(local name: " + field.getValue().getName() + ")"); } }); //handle errors field.getUploader().addErrorListener(new Plupload.ErrorListener() { @Override public void onError(PluploadError error) { Notification.show("There was an error: " + error.getMessage(), Notification.Type.ERROR_MESSAGE); } });
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
- updated Vaadin compatibility to 7.7.3
- updated plupload library to 2.1.9
- updated commons-fileupload to 1.3.2
- updated commons-io to 2.5
- updated gson to 2.7
- examples app runs on Vaadin 7.7.3 and plupload addon 2.1.0
- Released
- 2016-10-18
- Maturity
- STABLE
- License
- Apache License 2.0
Compatibility
- Framework
- Vaadin 7.3+
- Browser
- Firefox
- Opera
- Safari
- Google Chrome
- Internet Explorer
- Internet Explorer
Plupload wrapper for Vaadin 7.x - Vaadin Add-on Directory
Plupload library integration add-on for Vaadin Framework 7.xIssue Tracker
Source Code
README
Original Plupload library site
Plupload wrapper for Vaadin 7.x version 1.5.4
Removed a DevUI class from build - it's for development purposes only
Plupload wrapper for Vaadin 7.x version 1.6.2
[new] server side event: ChunkUploaded - for advanced, low level streaming access
[new] ability to disable saving uploaded files on disk - handy, in the above new feature is in use
[new] added some javadoc to API methods
[removed] methods of PluploadField: getStartButton, getStopButton, getItemsMap
[changed] when using PluploadField with byte[] as the return class, the field doesn't use temp files anymore. Instead the new chunks streaming feature is used. The class can be now used in environments that don't support writing files on disk.
Plupload wrapper for Vaadin 7.x version 2.0.0
[new] a completely new, flexible way of handling uploaded files on the server side (see README file, 'Server side upload handling' section for more info)
[new] PluploadFile::getUploadedFileAs(Class
Plupload wrapper for Vaadin 7.x version 2.1.0
- updated Vaadin compatibility to 7.7.3
- updated plupload library to 2.1.9
- updated commons-fileupload to 1.3.2
- updated commons-io to 2.5
- updated gson to 2.7
- examples app runs on Vaadin 7.7.3 and plupload addon 2.1.0