Failed to fetch when file has spaces in name.
See original GitHub issueHello!
When I try to upload a file that has a space in its name (like “FILE A”), I get this error.
Failed to create form data from content URI:content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2FFILE A.docx, Permission Denial: reading com.android.providers.downloads.DownloadStorageProvider uri content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2FFILE A.docx from pid=28475, uid=10155 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
code:
await RNFetchBlob.fetch('POST', url, {
token: 'token',
}, [
{
name: 'file0',
filename: file.name,
data: RNFetchBlob.wrap(decodeURI(fileURI)),
},
]);
If you remove the space from the name, everything works fine.
env platform: Android react-native: “0.62.2”, rn-fetch-blob: “^0.12.0” minSdkVersion = 23 compileSdkVersion = 28 targetSdkVersion = 28
p.s: RNFB.fs.exist(uri)
returns true
p.p.s:“FILE_A” for example uploads fine.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
Problem: Having file name contain Space and fetch the file
Closed 6 years ago. I am trying to get all file which is reside in one folder and file name have space like...
Read more >If the path of a file has space in between the uri cannot ...
In Java: URI uri = new File("spaces in file name").toURI();.
Read more >FetchGCSObject processor in NiFi fails to fetch files with ...
I am running into a problem with the NiFi fetchgcsobject processor.. It fails when trying to retrieve files with spaces in the file...
Read more >[Help] Cannot download file if the file name has spaces
when i use download API, it works well if download FileName does not has space. But return eroor 400 if download FileName has...
Read more >How to Read a Filename with Spaces in Linux
If you want to view such a file with space in the file name, use the same principle of enclosing the file names...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, had the problem too, solved it like this as path is not interpreted the same way in iOS and Android :
Encode the URI as well as shown below: