-
-
Notifications
You must be signed in to change notification settings - Fork 462
Closed
Description
Bug report
Summary
Using RN document picker to select a document with the copyTo option doesn't return the URI scheme on Android while it does for iOS
If you try to use the fileCopyUri to upload a file (using vanilla fetch) it works on iOS, but does not work on Android
Adding the file:// prefix, fixes the issue on android
Reproducible sample code
import RNDocumentPicker from 'react-native-document-picker';
const documentPickerOptions = {
type: [RNDocumentPicker.types.allFiles],
copyTo: 'cachesDirectory',
};
RNDocumentPicker.pick(documentPickerOptions)
.then(documents => documents.map(({ fileCopyUri, ...doc })=> {
const payload = {
...doc,
};
// When the URI is lacking uri scheme - file upload would fail
const hasScheme = /^.+:\/\//.test(fileResult.uri);
if (!hasScheme) {
payload.uri = `file://${fileCopyUri}`;
}
return payload;
});Steps to reproduce
- Use Document Picker with
copyTo: 'cachesDirectory'option - Inspect
fileCopyUriunder Android - nofile:///prefix - Inpsect
fileCopyUriunder iOS - hasfile:///prefix
Describe what you expected to happen:
- Use Document Picker with
copyTo: 'cachesDirectory'option fileCopyUrishould behave the same way on all Platforms- preferable all should have
file:///prefix - alternatively none should have it
- preferable all should have
Environment info
npx react-native info output:
System:
OS: Windows 10 10.0.19044
CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
Memory: 20.20 GB / 31.93 GB
Binaries:
Node: 14.18.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.15 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.14.15 - C:\Program Files\nodejs\npm.CMD
Watchman: 20210110.135312.0 - D:\watchman-v2021.01.11.00-windows\bin\watchman.EXE
SDKs:
Android SDK:
API Levels: 27, 28, 29, 30, 31
Build Tools: 29.0.2, 30.0.2, 31.0.0
System Images: android-29 | Google APIs Intel x86 Atom
Android NDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: Not Found
Visual Studio: 16.9.31025.194 (Visual Studio Community 2019)
Languages:
Java: Not Found
npmPackages:
@react-native-community/cli: 6.2.0 => 6.2.0
react: ^17.0.2 => 17.0.2
react-native: 0.66.4 => 0.66.4
react-native-windows: Not Found
npmGlobalPackages:
*react-native*: Not Found
library version: 7.1.3
iOS / Android version: ios 15 / Android 10
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels