React native Download Image from URL into Gallery folder Android iOS Example

Hello guys, we all have heard about a famous react native NPM library rn-fetch-blob. This library comes with amazing possibilities and features which make easy to use it for beginners. In this tutorial we would Download Image from URL into Gallery folder and save the image in downloads folder. First we would send the request to sever and fetch the file, after fetching the file we would rename the file using individual functions so each time if the file has same name on server we would rename the file in random order and save in our mobile phone’s downloads folder. So let’s get started :).

Note: Guys there is a problem with rn-fetch-blob library because it is not working properly in iOS devices. So for now the code is only working in Android devices.

Content in this project React native Download Image from URL into Gallery folder Android iOS Example Tutorial:

1. Open your react native project folder in command prompt like i did in below screenshot and execute below command to install the rn-fetch-blob library.

Screenshot of CMD:

2. After successfully done installation you need to execute the link command to link the newly installed rn-fetch-blob library to your current project root structure. Execute the below command to link library.

Screenshot of CMD:

3. Now your library is successfully linked to your current react native project. Next step is to open the AndroidManifest.xml file located in Your_React_Native_Project -> android -> app -> src -> main -> AndroidManifest.xml .

4. Put the below WRITE_EXTERNAL_STORAGE permission in it. This permission is required for accessing device storage.

5. We need to also add a intent filter named as DOWNLOAD_COMPLETE in intent section.

Source code of my AndroidManifest.xml file after making changes:

6. Now its time to start coding. Open your project’s App.js file, Delete all the previous code to start with clean slate. Import StyleSheet, Text, View, TouchableOpacity, Alert, PermissionsAndroid and Image component in your project.

7. Import RNFetchBlob component from rn-fetch-blob library.

8. Create a ASYNC stand alone function named as request_storage_runtime_permission(). In this function we would request for android’s runtime permission for accessing device storage. If you wish to learn more about how to request runtime permission in react native for android read my this tutorial.

9. Create your main export default class named as MainActivity. This would be our main class.

10. In MainActivity class create ASYNC componentDidMount() method and call the request_storage_runtime_permission() function using await method. This method will allow us to ask for runtime permission.

11. Create a function named as downloadImage() in your Main class. In this function we would pass the Image HTTP URL which we want to download and simply shows a alert after download complete.

12. Create another function named as getExtention() in your main class. Using this function we would get the file extension.

13. Creating a Image component & Touchable opacity button in render’s return block.

14. Creating Style.

15. Complete source code for App.js File :


React native Download Image from URL into Gallery folder


  1. Thank You sir

  2. How about ios? I try it but image not downloaded

  3. How about using CameraRoll api from RN itself? It can save the image to iPhone gallery

  4. How to create folder

  5. how to create folder in PictureDir

  6. hii sir how to download image in ios i try but image not show in device
    const { dirs: { DownloadDir, DocumentDir } } = RNFetchBlob.fs;
    const isIOS = Platform.OS === ‘ios’;
    const aPath ={ ios: DownloadDir, android: DownloadDir });
    const fPath = ${aPath}/${this.state.file_ex};
    const configOptions ={
    ios: {
    fileCache: true,
    path: fPath,
    // appendExt: ‘pdf’,

    if (isIOS) { // This iOS block works fine..
    .fetch(‘GET’, image_URL)
    .then(async (resp) => {
    console.log(“file “,resp)
    // This options is for file sharing in iOS. Works fine.
    const options = {
    title: ‘Receipt File’, // type: ‘pdf’,
    urls: [file://${fPath}],
    // await;
    // await RNFS.unlink(fPath);

    i got this resp
    data: “/var/mobile/Containers/Data/Application/90BC2373-1486-4D67-84D4-3DCD47A0E428/Downloads/doc_73.JPG”
    taskId: “6598unz555rzlmq219p229”
    type: “path”

  7. bro some time the image download is not working.any idea

  8. its take to much time to download any ideas

Leave a Reply

Your email address will not be published. Required fields are marked *