diff --git a/src/index.ts b/src/index.ts index 15b81a4f..4af7930d 100755 --- a/src/index.ts +++ b/src/index.ts @@ -96,13 +96,24 @@ function decodeContents(b64: string, encoding: Encoding): string { } function getArrayBuffer(filePath: string): Promise { - return new Promise((resolve, reject) => { + return new Promise(async (resolve, reject) => { if (!blobJSIHelper) { reject(new Error('react-native-blob-jsi-helper is not installed')); return; } - fetch(filePath) + let originalFilepath = filePath; + if (filePath.includes('content://')) { + const stat = await RNFSManager.stat(normalizeFilePath(filePath)); + + if (stat.originalFilepath.includes('file://')) { + originalFilepath = stat.originalFilepath; + } else { + originalFilepath = `file://${stat.originalFilepath}`; + } + } + + fetch(originalFilepath) .then((response) => response.blob()) .then((blob) => { resolve(blobJSIHelper.getArrayBufferForBlob(blob));