Simple Download File React Native

Hello , react native i think very easy to use and learn. If you need to download something(file, image, pdf, etc) you can use react-native-fetch-blob. May be i want to share part of my project.

You can use this library :

Features Library

  • Transfer data directly from/to storage without BASE64 bridging
  • File API supports regular files, Asset files, and CameraRoll files
  • Native-to-native file manipulation API, reduce JS bridging performance loss
  • File stream support for dealing with large file
  • Blob, File, XMLHttpRequest polyfills that make browser-based library available in RN (experimental)
  • JSON stream supported base on Oboe.js

It’ sample code for download file :

var date = new Date();
var url = "";
var ext = this.extention(url);
ext = "."+ext[0];
const { config, fs } = RNFetchBlob
let PictureDir = fs.dirs.PictureDir
let options = {
fileCache: true,
addAndroidDownloads : {
useDownloadManager : true,
notification : true,
path: PictureDir + "/image_"+Math.floor(date.getTime() + date.getSeconds() / 2)+ext,
description : 'Image'
config(options).fetch('GET', url).then((res) => {
Alert.alert("Success Downloaded");
return (/[.]/.exec(filename)) ? /[^.]+$/.exec(filename) : undefined;

Thanks for view my article, i hope it’s can help you.

Like what you read? Give Derry Berni Cahyady a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.