mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-03 03:38:33 +08:00
PL-8338 Client-tier bean for working with FileStorage using streams
This commit is contained in:
parent
4f2b912c4e
commit
82e1cb33a3
@ -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<InputStream> inputStreamSupplier,
|
||||
@Nullable Consumer<StreamingProgressEvent> streamingListener)
|
||||
@Nullable StreamingProgressListener streamingListener)
|
||||
throws FileStorageException, InterruptedException {
|
||||
fileStorageAPI.saveStream(fd, inputStreamSupplier.get());
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user