Skip to content

girish54321/ReactNativeDownloadDemo

Repository files navigation

React Native File Download πŸ”₯

In this repo you will find quick snippet for downloading file in React Native (android & iOS) App Screenshot

Installation πŸ”§

Install rn-fetch-blob in your project

npm

  npm i rn-fetch-blob

yarn

  yarn add rn-fetch-blob

Installation Android

Add required permission in AndroidManifest.xml

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />

Installation iOS

No changes required for iOS.

Usage πŸ€”

Copy DownloadFileServices.ts File into your project & import like below.

// import File in your code πŸ‘‡

import { DownloadFile } from "../DownloadFileServices";

function App() {
  return (
    <TouchableOpacity
      onPress={() => {
        let fileUrl = "Your File URL";
        DownloadFile(fileUrl); // Pass URL in function
      }}
    >
      <Text>Click Me</Text>
    </TouchableOpacity>
  );
}

Run Demo project locally πŸƒπŸ½β€β™€οΈ

Clone the project

  git clone https://github.com/girish54321/ReactNativeDownloadDemo.git

Go to the project directory

  cd ReactNativeDownloadDemo

Install dependencies

  yarn

Start the project

  yarn android_dev_debug

FAQ

How to use DownloadFileServices.ts file in vanilla javascript

Just rename DownloadFileServices.ts to DownloadFileServices.js and remove types. πŸ˜‡

Contributing πŸ™πŸ½

Contributions are always welcome!