React-native-fs: Image doesn't appear in gallery after saving

Created on 31 May 2019  路  1Comment  路  Source: itinance/react-native-fs

When I download the image to ExternalStorageDirectoryPath in android
it does not appear in gallery.

Just when I restart my phone it appears

any help??

Most helpful comment

This code solves your problem.

import { CameraRoll } from 'react-native';

const imagePath = `${RNFS.TemporaryDirectoryPath}/${((Math.random() * 1000) | 0)}.jpeg`;

RNFS.downloadFile({
        fromUrl: imageUrl,
        toFile: imagePath,
        progress: (e) => console.log(e),
        begin: (s) => console.log(s),
    }).promise
        .then(() => {
            CameraRoll.saveToCameraRoll(id, "photo");
        })
        .catch((e) => {
        })

>All comments

This code solves your problem.

import { CameraRoll } from 'react-native';

const imagePath = `${RNFS.TemporaryDirectoryPath}/${((Math.random() * 1000) | 0)}.jpeg`;

RNFS.downloadFile({
        fromUrl: imageUrl,
        toFile: imagePath,
        progress: (e) => console.log(e),
        begin: (s) => console.log(s),
    }).promise
        .then(() => {
            CameraRoll.saveToCameraRoll(id, "photo");
        })
        .catch((e) => {
        })
Was this page helpful?
0 / 5 - 0 ratings

Related issues

barnir picture barnir  路  3Comments

nishanBende picture nishanBende  路  3Comments

onzag picture onzag  路  3Comments

zaheerahmad92001 picture zaheerahmad92001  路  3Comments

PimDeWitte picture PimDeWitte  路  4Comments