Skip to content

Commit

Permalink
simplify fileAppend (no local copy of the existing data)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Nov 13, 2023
1 parent e3edd80 commit b2f257e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
4 changes: 2 additions & 2 deletions build.number
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Wed Nov 08 18:22:07 CET 2023
build.number=8
#Mon Nov 13 16:47:10 CET 2023
build.number=9
27 changes: 9 additions & 18 deletions source/java/src/org/lucee/extension/resource/s3/S3Resource.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
*/
package org.lucee.extension.resource.s3;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -261,24 +259,17 @@ public OutputStream getOutputStream(boolean append) throws IOException {
}

try {
byte[] barr = null;
if (append) {
InputStream is = null;
OutputStream os = null;
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
os = baos;
engine.getIOUtil().copy(is = getInputStream(), baos, false, false);
barr = baos.toByteArray();
}
finally {
Util.closeEL(is);
Util.closeEL(os);
}
}
/*
* byte[] barr = null; if (append) { InputStream is = null; OutputStream os = null; try {
* ByteArrayOutputStream baos = new ByteArrayOutputStream(); os = baos; engine.getIOUtil().copy(is =
* getInputStream(), baos, false, false); barr = baos.toByteArray(); } finally { Util.closeEL(is);
* Util.closeEL(os); } }
*/

S3ResourceOutputStream os = new S3ResourceOutputStream(s3, bucketName, objectName, getInnerPath(), acl, location);
if (append && !(barr == null || barr.length == 0)) engine.getIOUtil().copy(new ByteArrayInputStream(barr), os, true, false);
if (append) {
engine.getIOUtil().copy(getInputStream(), os, true, false);
}
return os;
}
catch (IOException e) {
Expand Down

0 comments on commit b2f257e

Please sign in to comment.