use of com.vaadin.ui.Html5File in project Activiti by Activiti.
the class UploadComponent method drop.
// Drag and drop handling (DropHandler) ---------------------------------------------------------
public void drop(DragAndDropEvent event) {
WrapperTransferable transferable = (WrapperTransferable) event.getTransferable();
Html5File[] files = transferable.getFiles();
if (files != null && files.length > 0) {
// only support for one file upload at this moment
final Html5File file = files[0];
file.setStreamVariable(new StreamVariable() {
private static final long serialVersionUID = 1L;
public void streamingStarted(StreamingStartEvent event) {
// event doesnt matter here
uploadStarted(null);
}
public void streamingFinished(StreamingEndEvent event) {
// event doesnt matter here
uploadFinished(null);
}
public void streamingFailed(StreamingErrorEvent event) {
uploadFailed(null);
}
public void onProgress(StreamingProgressEvent event) {
updateProgress(event.getBytesReceived(), event.getContentLength());
}
public boolean listenProgress() {
return true;
}
public boolean isInterrupted() {
return false;
}
public OutputStream getOutputStream() {
return receiver.receiveUpload(file.getFileName(), file.getType());
}
});
}
}
Aggregations