]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/attachment/FileAttachmentsStorage.java
Stabilize attachments and events
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.simple / src / main / java / org / argeo / slc / core / attachment / FileAttachmentsStorage.java
index 45bf35fb5e9d14514a571a3a645bdeb9bc3198f0..0e70805c061c602f10e678d9063ef176f503d060 100644 (file)
@@ -36,8 +36,9 @@ public class FileAttachmentsStorage implements AttachmentsStorage {
                try {
                        byte[] buffer = new byte[1024 * 1024];
                        in = new FileInputStream(file);
-                       while (in.read(buffer) >= 0) {
-                               outputStream.write(buffer);
+                       int read = -1;
+                       while ((read = in.read(buffer)) >= 0) {
+                               outputStream.write(buffer, 0, read);
                        }
                } catch (IOException e) {
                        throw new SlcException("Cannot write attachment " + attachment