joerghoh commented on code in PR #2621:
URL: https://github.com/apache/jackrabbit-oak/pull/2621#discussion_r2559911648
##########
oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3Backend.java:
##########
@@ -1323,6 +1331,48 @@ private static String getIdentifierName(String key) {
return key.substring(0, 4) + key.substring(5);
}
+ @NotNull
+ private AsyncRequestBody getRequestBody(final InputStream input, final
ExecutorService executor,
+ final PutObjectRequest.Builder
builder) throws IOException {
+ final AsyncRequestBody body;
+ if (Objects.equals(RemoteStorageMode.S3,
properties.get(S3Constants.MODE))) {
+ body = AsyncRequestBody.fromInputStream(input, null, executor);
+ } else {
+ // for GCP we need to know the length in advance, else it won't
work.
+ final long length;
+ if (input instanceof FileInputStream) {
+ final FileInputStream fis = (FileInputStream) input;
+ // if the file is modified after opening, the size may not
reflect the latest changes
+ length = fis.getChannel().size();
+ body = AsyncRequestBody.fromInputStream(input, length,
executor);
+ } else if (input instanceof ByteArrayInputStream) {
+ length = input.available();
+ body = AsyncRequestBody.fromInputStream(input, length,
executor);
+ } else if (input.markSupported()) {
+ // in case the inputStream supports mark & reset
+ input.mark(Integer.MAX_VALUE);
+ length = IOUtils.consume(input);
+ input.reset();
+ body = AsyncRequestBody.fromInputStream(input, length,
executor);
+ } else {
Review Comment:
indeed, that's correct.
I am not 100% happy with that temp file approach either especially when
these files are cleaned up on shutdown; meaning that they accumulate over time
and can consume all disk space.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]