Search in sources :

Example 1 with FileInfo

use of com.haulmont.cuba.gui.upload.FileUploadingAPI.FileInfo in project cuba by cuba-platform.

the class DesktopFileMultiUploadField method uploadFiles.

protected void uploadFiles(File[] files) {
    for (File file : files) {
        try {
            fireFileUploadStart(file.getName(), file.length());
            FileInfo fileInfo = fileUploading.createFile();
            UUID tempFileId = fileInfo.getId();
            File tmpFile = fileInfo.getFile();
            FileUtils.copyFile(file, tmpFile);
            filesMap.put(tempFileId, file.getName());
            fireFileUploadFinish(file.getName(), file.length());
        } catch (Exception ex) {
            Messages messages = AppBeans.get(Messages.NAME);
            String uploadError = messages.formatMessage(DesktopFileMultiUploadField.class, "multiupload.uploadError", file.getName());
            TopLevelFrame topLevelFrame = DesktopComponentsHelper.getTopLevelFrame(this);
            topLevelFrame.showNotification(uploadError, Frame.NotificationType.ERROR);
            fireFileUploadError(file.getName(), file.length(), ex);
        }
    }
    fireQueueUploadComplete();
}
Also used : Messages(com.haulmont.cuba.core.global.Messages) FileInfo(com.haulmont.cuba.gui.upload.FileUploadingAPI.FileInfo) TopLevelFrame(com.haulmont.cuba.desktop.TopLevelFrame) File(java.io.File)

Aggregations

Messages (com.haulmont.cuba.core.global.Messages)1 TopLevelFrame (com.haulmont.cuba.desktop.TopLevelFrame)1 FileInfo (com.haulmont.cuba.gui.upload.FileUploadingAPI.FileInfo)1 File (java.io.File)1