From e2e3058a497f43f34f2fcfadf6b63de9211be659 Mon Sep 17 00:00:00 2001 From: Adam Wagner Date: Thu, 11 May 2017 13:13:10 +0300 Subject: Make it possible to upload files by dropping them onto a drop target (#9277) Fixes #8891 --- documentation/advanced/advanced-dragndrop.asciidoc | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'documentation') diff --git a/documentation/advanced/advanced-dragndrop.asciidoc b/documentation/advanced/advanced-dragndrop.asciidoc index 57764b55dd..6390eff201 100644 --- a/documentation/advanced/advanced-dragndrop.asciidoc +++ b/documentation/advanced/advanced-dragndrop.asciidoc @@ -287,4 +287,68 @@ When dragging data over a drop target Grid's row, depending on the drop mode and (((range="endofrange", startref="term.advanced.dragndrop"))) +== Drag and Drop Files +Files can be uploaded to the server by dropping them onto a file drop target. To make a component a file drop target, apply the [classname]#FileDropTarget# extension to it by creating a new instance and passing the component as first constructor parameter to it. + +You can handle the dropped files with the `FileDropHandler` that you add as the second constructor parameter. The [classname]#FileDropEvent#, received by the handler, contains information about the dropped files such as file name, file size and mime type. +In the handler you can decide if you would like to upload each of the dropped files. + +To start uploading a file, set a `StreamVariable` to it. The stream variable provides an output stream where the file will be written and has callback methods for all the stages of the upload process. + +[source,java] +---- +Label dropArea = new Label("Drop files here"); +FileDropTarget