MediaLibrary.deleteAssetsAsync

Hi,
I Don’t achieve to delete an asset created befor with:

    const dirPath = `${FileSystem.documentDirectory}${Config.NAME}`;

    await FileSystem.makeDirectoryAsync(dirPath, { intermediates: true }).catch((e) => {
      console.log(e, 'Directory exists');
    });

    FileSystem.moveAsync({
      from: uri,
      to: `${dirPath}/${name}.jpg`,
    }).then(async () => {
      const asset = await MediaLibrary.createAssetAsync(`${dirPath}/${name}.jpg`);
      const album = await MediaLibrary.getAlbumAsync(Config.NAME);

      if (album === null) {
        MediaLibrary.createAlbumAsync(Config.NAME, asset, false);
      } else {
        MediaLibrary.addAssetsToAlbumAsync([asset], album.id, false);
      }

  this.setState({
       asset, album,
      });
});

then I try to delete it :

MediaLibrary.deleteAssetsAsync([this.state.asset]).catch(err => console.log(err));
MediaLibrary.removeAssetsFromAlbumAsync([this.state.asset], this.state.album).catch(err => console.log(err));

but nothing happens…
My picture is created, I can see it. But when I delete it, it is still there…

Is there something wrong in my code ?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.