Skip to content

Commit 2568a62

Browse files
authored
Merge pull request #298 from ammarahm-ed/patch-1
fix: reading file from assets
2 parents 58eb6ab + 7448173 commit 2568a62

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilFS.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ static void readFile(String path, String encoding, final boolean transformFile,
257257
if (resolved != null && resolved.startsWith(ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET)) {
258258
String assetName = path.replace(ReactNativeBlobUtilConst.FILE_PREFIX_BUNDLE_ASSET, "");
259259
// This fails should an asset file be >2GB
260-
length = (int) ReactNativeBlobUtilImpl.RCTContext.getAssets().openFd(assetName).getLength();
261-
bytes = new byte[length];
262260
InputStream in = ReactNativeBlobUtilImpl.RCTContext.getAssets().open(assetName);
261+
length = in.available();
262+
bytes = new byte[length];
263263
bytesRead = in.read(bytes, 0, length);
264264
in.close();
265265
}

0 commit comments

Comments
 (0)