Native file download utility for react-native
Note: this project is under development and functionality will improve over time. Currently it provides only the bare minimum of functionality.
npm install react-native-file-download --save
Note that does not support Android.
- In XCode, in the project navigator right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-file-download
and addRNFileDownload.xcodeproj
- Add
libRNFileDownload.a
(from 'Products' under RNFileDownload.xcodeproj) to your project'sBuild Phases
➜Link Binary With Libraries
phase - Look for Header Search Paths and make sure it contains both
$(SRCROOT)/../react-native/React
and$(SRCROOT)/../../React
- mark both as recursive - Run your project (
Cmd+R
)
require it in your file
const FileDownload = require('react-native').NativeModules.RNFileDownload
download(source: string, target: string): Promise
download file from source to target
Example
FileDownload.download(`url`, `folderPath`)
.then(() => {
console.log('downloaded!')
})
catch((error) => {
console.log(error)
})