浏览代码

Update advanced-dragndrop.asciidoc (#10680)

* Update advanced-dragndrop.asciidoc

Fixing example of Drag and drop code.
Resolves https://github.com/vaadin/framework/issues/10512

* Update advanced-dragndrop.asciidoc

Removed unnecessary spaces

* Update advanced-dragndrop.asciidoc

Removed unnecessary spaces
tags/8.4.0.alpha1
Anastasia Smirnova 6 年前
父节点
当前提交
0c5e445058
共有 1 个文件被更改,包括 13 次插入3 次删除
  1. 13
    3
      documentation/advanced/advanced-dragndrop.asciidoc

+ 13
- 3
documentation/advanced/advanced-dragndrop.asciidoc 查看文件

@@ -443,7 +443,7 @@ To start uploading a file, set a `StreamVariable` to it. The stream variable pro
Label dropArea = new Label("Drop files here");
FileDropTarget<Label> dropTarget = new FileDropTarget<>(dropArea, event -> {

List<Html5File> files = event.getFiles();
Collection<Html5File> files = event.getFiles();
files.forEach(file -> {
// Max 1 MB files are uploaded
if (file.getFileSize() <= 1024 * 1024) {
@@ -452,8 +452,13 @@ FileDropTarget<Label> dropTarget = new FileDropTarget<>(dropArea, event -> {
// Output stream to write the file to
@Override
public OutputStream getOutputStream() {
return new FileOutputStream("/path/to/files/"
+ file.getFileName());
try{
return new FileOutputStream("/path/to/files/"
+ file.getFileName());
}catch (FileNotFoundException e) {
e.printStackTrace();
}
return null;
}

// Returns whether onProgress() is called during upload
@@ -489,6 +494,11 @@ FileDropTarget<Label> dropTarget = new FileDropTarget<>(dropArea, event -> {
Notification.show("Stream failed, fileName="
+ event.getFileName());
}

@Override
public boolean isInterrupted() {
return false;
}
});
}
}

正在加载...
取消
保存