From c6b8c74183acc9364a63e684f7f3418cd66cf7ba Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1s=C3=A1ry=20D=C3=A1niel?= Date: Fri, 20 Jul 2018 10:45:10 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C31200 --- .../src/user/commons/StoreUri.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/server/user.jobengine.osgi.commons/src/user/commons/StoreUri.java b/server/user.jobengine.osgi.commons/src/user/commons/StoreUri.java index 12a5a7b7..3ef48037 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/StoreUri.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/StoreUri.java @@ -99,20 +99,25 @@ public class StoreUri extends EntityBase implements Serializable { // } result.setName(targetFileName); result.setSize(source.getSize()); - OutputStream outputStream = outputLister.getOutputStream(result); - if (outputStream == null) - throw new Exception("OutputStream is null!"); ProgressEvent progressEvent = new ProgressEvent(this, 0); StatusEvent statusEvent = new StatusEvent(this); long size = source.getSize(); BufferedInputStream in = new BufferedInputStream(inputStream, BUFFER_SIZE); - BufferedOutputStream out = new BufferedOutputStream(outputStream, BUFFER_SIZE); + OutputStream outputStream = null; + BufferedOutputStream out = null; try { int lastPercent = 0; while ((byteCount = in.read(buffer, 0, BUFFER_SIZE)) != -1) { + if (out == null) { + outputStream = outputLister.getOutputStream(result); + if (outputStream == null) + throw new Exception("OutputStream is null!"); + out = new BufferedOutputStream(outputStream, BUFFER_SIZE); + } + out.write(buffer, 0, byteCount); uploadedBytes += byteCount; -- 2.54.0