Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

[Android] Downloading an image fails when directory doesn't exist but works on iOS #215

@dwilt

Description

@dwilt

We are downloading some images in our application. It's working beautifully on iOS. Here is our fetch:

const documentsDir = RNFetchBlob.fs.dirs.DocumentDir;
export const storyAssetsPath = `${documentsDir}/storyAssets`;

const downloadImage = async url => {
    const id = uuid();
    const filename = `${id}.jpg`;
    const path = `${storyAssetsPath}/${filename}`;

    await RNFetchBlob.config({
        fileCache: true,
        path
    }).fetch('GET', url);

    return filename;
};

Note the storyAssets folder that we're downloading the image into.

On Android, if the folder does not exist, it will not download the images correctly. It will seemingly succeed as the res comes back from the .fetch successfully but the images aren't actually there. If I manually create the folder on the device:

adb shell
root@vbox86p:/ $run-as com.greatjonesstreet
root@vbox86p:/ $ cd /data/data/com.greatjonesstreet
root@vbox86p:/data/data/com.greatjonesstreet $ mkdir storyAssets

the images download correctly. Any ideas?

react-native: 0.37.0
react-native-fetch-blob: 0.10.0

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions