From 82e1cb33a32b5ec4a9cae84e12289c511c7e603b Mon Sep 17 00:00:00 2001 From: Yuriy Artamonov Date: Tue, 4 Apr 2017 13:14:15 +0400 Subject: [PATCH] PL-8338 Client-tier bean for working with FileStorage using streams --- .../core/src/com/haulmont/cuba/core/sys/FileLoaderImpl.java | 3 +-- .../gui/src/com/haulmont/cuba/gui/upload/FileUploading.java | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/core/src/com/haulmont/cuba/core/sys/FileLoaderImpl.java b/modules/core/src/com/haulmont/cuba/core/sys/FileLoaderImpl.java index 15c05eb6fb..e832ef1f64 100644 --- a/modules/core/src/com/haulmont/cuba/core/sys/FileLoaderImpl.java +++ b/modules/core/src/com/haulmont/cuba/core/sys/FileLoaderImpl.java @@ -25,7 +25,6 @@ import org.springframework.stereotype.Component; import javax.annotation.Nullable; import javax.inject.Inject; import java.io.InputStream; -import java.util.function.Consumer; import java.util.function.Supplier; @Component(FileLoader.NAME) @@ -40,7 +39,7 @@ public class FileLoaderImpl implements FileLoader { @Override public void saveStream(FileDescriptor fd, Supplier inputStreamSupplier, - @Nullable Consumer streamingListener) + @Nullable StreamingProgressListener streamingListener) throws FileStorageException, InterruptedException { fileStorageAPI.saveStream(fd, inputStreamSupplier.get()); } diff --git a/modules/gui/src/com/haulmont/cuba/gui/upload/FileUploading.java b/modules/gui/src/com/haulmont/cuba/gui/upload/FileUploading.java index fde9980120..63c706b11d 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/upload/FileUploading.java +++ b/modules/gui/src/com/haulmont/cuba/gui/upload/FileUploading.java @@ -261,9 +261,9 @@ public class FileUploading implements FileUploadingAPI, FileUploadingMBean { }; if (listener != null) { - fileLoader.saveStream(fileDescr, inputStreamSupplier, e -> { + fileLoader.saveStream(fileDescr, inputStreamSupplier, transferredBytes -> { try { - listener.progressChanged(fileId, e.getTransferredBytes(), fileSize); + listener.progressChanged(fileId, transferredBytes, fileSize); } catch (InterruptedException ie) { // if thread is already interrupted we will restore interrupted flag Thread.currentThread().interrupt();