From: Vásáry Dániel Date: Fri, 20 Jul 2018 10:45:10 +0000 (+0000) Subject: git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube... X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=c6b8c74183acc9364a63e684f7f3418cd66cf7ba;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C31200 --- 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;