react-native-fetch-blob
react-native-fetch-blob copied to clipboard
Process file:// URIs on iOS.
Hi, I've been using this package in conjunction with react-native-document-picker to select and upload files from iOS device.
Picker package opens standard iOS file picker which returns URI like file:///private/var...
as result.
When I pass such URI in parameters for fetch
function using wrap
helper, it reports that selected file doesn't exist.
The issue is that here this URI is treated as a simple path and file existence request returns NO
.
If I strip file://
part before calling wrap
, it works as expected
Is it possible to add handling for file URIs there so that there's no need of additional preparations? Or is there an additional setting that should be used in this case?
Versions: RN 0.42.3, RNFB 0.10.5
I have same problem
Same issue, any news on this?
Is this really an issue?
If I strip
file://
part before calling wrap, it works as expected
The documentation says a "path" is expected, and doing so seems simple enough. Sure code could be added to RNFB stripping file://
, but the app's code can do it just as easily.
I'm facing the same issue but the suggestions above didn't help.
I'm using react-native-document-picker as well as this RNFetchBlob and it seems to work fine for images and PDF files, but when I pick any other document (.docx, .pages, etc..) I always get RNFetchBlob.fetchBlobForm failed to create request body
This is the code that handles the upload. Is there anything I'm missing?
// Removes unwanted start of fileDir string
const cleanFilePath = fileDir.replace('file://', '');
const body = [
{
name: 'entity_document',
data: JSON.stringify(docProps),
type: 'application/json'
},
{
name: 'VersionData',
filename: fileName,
data: RNFetchBlob.wrap(cleanFilePath),
type: fileType
}
];
RNFetchBlob.fetch(
'POST',
`${instanceUrl}/services/data/v40.0/sobjects/ContentVersion`,
{
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'multipart/form-data'
},
body
)
.then(res => {
...
});
created a PR in the fork: https://github.com/joltup/rn-fetch-blob/pull/211
I'm facing the same issue but the suggestions above didn't help.
I'm using react-native-document-picker as well as this RNFetchBlob and it seems to work fine for images and PDF files, but when I pick any other document (.docx, .pages, etc..) I always get RNFetchBlob.fetchBlobForm failed to create request body
This is the code that handles the upload. Is there anything I'm missing?
// Removes unwanted start of fileDir string const cleanFilePath = fileDir.replace('file://', ''); const body = [ { name: 'entity_document', data: JSON.stringify(docProps), type: 'application/json' }, { name: 'VersionData', filename: fileName, data: RNFetchBlob.wrap(cleanFilePath), type: fileType } ]; RNFetchBlob.fetch( 'POST', `${instanceUrl}/services/data/v40.0/sobjects/ContentVersion`, { Authorization: `Bearer ${accessToken}`, 'Content-Type': 'multipart/form-data' }, body ) .then(res => { ... });
How you solved it?