You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/05/05 07:11:19 UTC
[camel] branch main updated: CAMEL-17861 (#7493)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 35da754a044 CAMEL-17861 (#7493)
35da754a044 is described below
commit 35da754a0448b3b598752a1250f7dfaf171a8a4e
Author: muellerch2293 <53...@users.noreply.github.com>
AuthorDate: Thu May 5 09:11:14 2022 +0200
CAMEL-17861 (#7493)
Co-authored-by: at00202766 <ch...@spar-ics.com>
---
.../component/azure/storage/blob/BlobUtils.java | 27 +++++++++++++++++-----
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/components/camel-azure/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/BlobUtils.java b/components/camel-azure/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/BlobUtils.java
index 02ada37d4eb..c4663dd4c09 100644
--- a/components/camel-azure/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/BlobUtils.java
+++ b/components/camel-azure/camel-azure-storage-blob/src/main/java/org/apache/camel/component/azure/storage/blob/BlobUtils.java
@@ -16,13 +16,13 @@
*/
package org.apache.camel.component.azure.storage.blob;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.util.ObjectHelper;
-import org.apache.commons.io.IOUtils;
public final class BlobUtils {
@@ -33,11 +33,26 @@ public final class BlobUtils {
return ObjectHelper.isEmpty(exchange) ? null : exchange.getIn();
}
- public static Long getInputStreamLength(final InputStream inputStream) throws IOException {
- final long length = IOUtils.toByteArray(inputStream).length;
- inputStream.reset();
-
- return length;
+ public static long getInputStreamLength(InputStream is) throws IOException {
+ if (!is.markSupported()) {
+ return -1;
+ }
+ if (is instanceof ByteArrayInputStream) {
+ return is.available();
+ }
+ long size = 0;
+ try {
+ is.mark(1024);
+ int i = is.available();
+ while (i > 0) {
+ long skip = is.skip(i);
+ size += skip;
+ i = is.available();
+ }
+ } finally {
+ is.reset();
+ }
+ return size;
}
public static String getContainerName(final BlobConfiguration configuration, final Exchange exchange) {