react native download as blob unsupported
See original GitHub issueLooks like there’s an error when calling filesDownload in a react native app. Output error:
{ [Invariant Violation: The provided value 'blob' is unsupported in this environment.] line: 2074, column: 16, sourceURL: 'http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false', name: 'Invariant Violation', framesToPop: 1 }
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Unsupported URL #352 - wkh237/react-native-fetch-blob
I'm using this package as a replacement for JS Fetch. I have calls to different URLs. all works fine except one :.
Read more >Format error when downloading Blob from React
I'm trying to download a Blob from React that can be either a PDF or an image(jpg, jpeg, png...). PDF's are downloading good...
Read more >How to Download an Image in React Native from any URL
To download an image using rn-fetch-blob we will use the RNFetchBlob component which provides a fetch method with some different configuration. Here is...
Read more >react-native-blob-util - npm
A module provides upload, download, and files access API. Supports file stream read/write for process large files.. Latest version: 0.17.0, ...
Read more >Download Files in React Native with RNFetchBlob
Download Files in React Native with RNFetchBlob. A concise and easy-to-follow guide on downloading files in React Native apps.
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
@RileyTomasek @evanbattaglia Couldn’t make it work for large files or some formats. Managed to get it working using react-native-fs’ downloadFile and calling Dropbox’s download HTTP endpoint instead
RNFS.downloadFile({
fromUrl: "https://content.dropboxapi.com/2/files/download",
toFile: localPath,
headers: {"Authorization": "Bearer XXXXXX",
"Dropbox-API-Arg": JSON.stringify({path: PATH})}
}).promise.then((response) => {
if (response.statusCode == 200) {
console.log('FILES Downloaded!')
} else {
console.log('SERVER ERROR')
}})
Indeed, https://github.com/evanbattaglia/dropbox-sdk-js/commit/fbb202abbcf9e1a359293892863e8e155b471c90 seems to work for me.
_Edit_: I’ve discovered that a better way to get binary data for React Native is with ArrayBuffers (e.g.
this.xhr.responseType = 'arraybuffer'
):https://github.com/dropbox/dropbox-sdk-js/compare/master...evanbattaglia:evanbattaglia/download-react-native?expand=1
With this ArrayBuffer to base64 gist (https://gist.github.com/jonleighton/958841) you can then write the file out with react-native-fs, with e.g.:
Kind of awkward but the best I’ve found so far.
Edit: See rubengarciam’s solution below, it works for me and is simpler.