下载的文件在哪里?

Where is the downloaded file?

我在 Vaadin8 项目中使用上传组件在服务器上上传文件,如本页源代码所示:

https://demo.vaadin.com/sampler/#ui/data-input/other/upload

我在电脑上选择文件点击上传后,window打开和sampler里一样,进度条一直走到尽头,就是找不到文件在项目文件系统中找到。我应该做的另一个步骤是什么?如何配置上传文件的目标文件夹?

摘自此处的官方文档Receiving upload

The uploaded files are typically stored as files in a file system, in a database, or as temporary objects in memory. The upload component writes the received data to an java.io.OutputStream so you have plenty of freedom in how you can process the upload content.

所以在您的情况下,上传的文件存储为临时对象。在 V8 文档中示例被截断,但它在 V7 中呈现:接收上传数据

 public OutputStream receiveUpload(String filename,
                                      String mimeType) {
        // Create upload stream
        FileOutputStream fos = null; // Stream to write to
        try {
            // Open the file for writing.
            file = new File("/tmp/uploads/" + filename);
            fos = new FileOutputStream(file);
        } catch (final java.io.FileNotFoundException e) {
            new Notification("Could not open file<br/>",
                             e.getMessage(),
                             Notification.Type.ERROR_MESSAGE)
                .show(Page.getCurrent());
            return null;
        }
        return fos; // Return the output stream to write to
    }
 public void uploadSucceeded(SucceededEvent event) {
        // Show the uploaded file in the image viewer
        image.setVisible(true);
        image.setSource(new FileResource(file));
    }

所以我们的想法是,一旦上传成功,您就可以自己创建一个文件。