I am unable to download image in expo application(React Native for Android) after building my app file, but I am able to download image while debugging the application using expo client
import * as Sharing from 'expo-sharing';
import * as FileSystem from 'expo-file-system';
import * as MediaLibrary from 'expo-media-library';
import * as Permissions from "expo-permissions";
const downloadFtn = async () => {
console.log("downloadFtn");
const fileUri: string = `${FileSystem.documentDirectory}test.png`;
const downloadedFile: FileSystem.FileSystemDownloadResult = await FileSystem.downloadAsync("https://i.ibb.co/K5Tyv2C/img-5-1.png", fileUri);
console.log(FileSystem.documentDirectory);
console.log(downloadedFile.status);
if (downloadedFile.status != 200) {
console.log(downloadedFile);
} else {
const perm = await Permissions.askAsync(Permissions.MEDIA_LIBRARY);
if (perm.status != 'granted') {
return;
}
try {
const asset = await MediaLibrary.createAssetAsync(downloadedFile.uri);
const album = await MediaLibrary.getAlbumAsync('Download');
if (album == null) {
await MediaLibrary.createAlbumAsync('Download', asset, false);
} else {
await MediaLibrary.addAssetsToAlbumAsync([asset], album, false);
}
} catch (e) {
handleError(e);
}
}
}