Resolve delete on local upload.
This commit is contained in:
@@ -207,70 +207,70 @@ export function UploadProgress({
|
||||
if (Platform.OS === 'android') {
|
||||
//Create a new asset with the first file to delete.
|
||||
// console.log('Trying new delete.');
|
||||
try {
|
||||
await MediaLibrary.getPermissionsAsync(false);
|
||||
const albumremove = await MediaLibrary.removeAssetsFromAlbumAsync(
|
||||
filesToDelete,
|
||||
filesToDelete[0].albumId
|
||||
);
|
||||
Toast.show({
|
||||
type: 'info',
|
||||
text1: 'removeAssetsFromAlbumAsync',
|
||||
text2: JSON.stringify(albumremove),
|
||||
autoHide: false,
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("🚀 ~ onDone ~ error:", error)
|
||||
Toast.show({
|
||||
type: 'error',
|
||||
text1: 'removeAssetsFromAlbumAsync',
|
||||
text2: JSON.stringify(error),
|
||||
autoHide: false,
|
||||
});
|
||||
}
|
||||
await MediaLibrary.getPermissionsAsync(false);
|
||||
// try {
|
||||
// const albumremove = await MediaLibrary.removeAssetsFromAlbumAsync(
|
||||
// filesToDelete,
|
||||
// filesToDelete[0].albumId
|
||||
// );
|
||||
// Toast.show({
|
||||
// type: 'info',
|
||||
// text1: 'removeAssetsFromAlbumAsync',
|
||||
// text2: JSON.stringify(albumremove),
|
||||
// autoHide: false,
|
||||
// });
|
||||
// } catch (error) {
|
||||
// console.log("🚀 ~ onDone ~ error:", error)
|
||||
// Toast.show({
|
||||
// type: 'error',
|
||||
// text1: 'removeAssetsFromAlbumAsync',
|
||||
// text2: JSON.stringify(error),
|
||||
// autoHide: false,
|
||||
// });
|
||||
// }
|
||||
|
||||
try {
|
||||
const delres = await MediaLibrary.deleteAssetsAsync(
|
||||
filesToDelete.map((f) => f.id)
|
||||
);
|
||||
// try {
|
||||
// const delres = await MediaLibrary.deleteAssetsAsync(
|
||||
// filesToDelete.map((f) => f.id)
|
||||
// );
|
||||
|
||||
Toast.show({
|
||||
type: 'info',
|
||||
text1: 'deleteAssetsAsync',
|
||||
text2: JSON.stringify(delres),
|
||||
autoHide: false,
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("🚀 ~ onDone ~ error:", error)
|
||||
Toast.show({
|
||||
type: 'error',
|
||||
text1: 'deleteAssetsAsync',
|
||||
text2: JSON.stringify(error),
|
||||
autoHide: false,
|
||||
});
|
||||
}
|
||||
// Toast.show({
|
||||
// type: 'info',
|
||||
// text1: 'deleteAssetsAsync',
|
||||
// text2: JSON.stringify(delres),
|
||||
// autoHide: false,
|
||||
// });
|
||||
// } catch (error) {
|
||||
// console.log("🚀 ~ onDone ~ error:", error)
|
||||
// Toast.show({
|
||||
// type: 'error',
|
||||
// text1: 'deleteAssetsAsync',
|
||||
// text2: JSON.stringify(error),
|
||||
// autoHide: false,
|
||||
// });
|
||||
// }
|
||||
|
||||
try {
|
||||
const res = Promise.all(
|
||||
filesToDelete.map((f) =>
|
||||
FileSystem.deleteAsync(f.uri, { idempotent: true })
|
||||
)
|
||||
);
|
||||
Toast.show({
|
||||
type: 'info',
|
||||
text1: 'FileSystemDelete',
|
||||
text2: JSON.stringify(res),
|
||||
autoHide: false,
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("🚀 ~ onDone ~ error:", error)
|
||||
Toast.show({
|
||||
type: 'error',
|
||||
text1: 'FileSystemDelete',
|
||||
text2: JSON.stringify(error),
|
||||
autoHide: false,
|
||||
});
|
||||
}
|
||||
// try {
|
||||
// const res = Promise.all(
|
||||
// filesToDelete.map((f) =>
|
||||
// FileSystem.deleteAsync(f.uri, { idempotent: true })
|
||||
// )
|
||||
// );
|
||||
// Toast.show({
|
||||
// type: 'info',
|
||||
// text1: 'FileSystemDelete',
|
||||
// text2: JSON.stringify(res),
|
||||
// autoHide: false,
|
||||
// });
|
||||
// } catch (error) {
|
||||
// console.log("🚀 ~ onDone ~ error:", error)
|
||||
// Toast.show({
|
||||
// type: 'error',
|
||||
// text1: 'FileSystemDelete',
|
||||
// text2: JSON.stringify(error),
|
||||
// autoHide: false,
|
||||
// });
|
||||
// }
|
||||
|
||||
try {
|
||||
const album = await MediaLibrary.createAlbumAsync(
|
||||
@@ -288,8 +288,8 @@ export function UploadProgress({
|
||||
}
|
||||
const deleteResult = await MediaLibrary.deleteAlbumsAsync(album);
|
||||
Toast.show({
|
||||
type: 'info',
|
||||
text1: 'deleteAlbumsAsync',
|
||||
type: 'success',
|
||||
text1: 'Pictures deleted succesfully.',
|
||||
text2: JSON.stringify(deleteResult),
|
||||
autoHide: false,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user