From a072a1a355bd72b2b24f2cb2dc7865664ec93dc8 Mon Sep 17 00:00:00 2001 From: Trey Reynolds Date: Sat, 26 Feb 2022 16:46:04 -0800 Subject: [PATCH] Fix content length to be capped at Integer.MAX_VALUE for downloads --- .../Response/ReactNativeBlobUtilFileResp.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/android/src/main/java/com/ReactNativeBlobUtil/Response/ReactNativeBlobUtilFileResp.java b/android/src/main/java/com/ReactNativeBlobUtil/Response/ReactNativeBlobUtilFileResp.java index f38d17784..81bbd0852 100644 --- a/android/src/main/java/com/ReactNativeBlobUtil/Response/ReactNativeBlobUtilFileResp.java +++ b/android/src/main/java/com/ReactNativeBlobUtil/Response/ReactNativeBlobUtilFileResp.java @@ -72,6 +72,10 @@ public MediaType contentType() { @Override public long contentLength() { + if (originalBody.contentLength() > Integer.MAX_VALUE) { + // This is a workaround for a bug Okio buffer where it can't handle larger than int. + return Integer.MAX_VALUE; + } return originalBody.contentLength(); }