How to get reference filepath or id in MediaLibrary

The process is simple, I read an image through the imagepicker and I plan to save a copy in an album.

I would like to save an image with Media Library.create Album Async or MediaLibrary.addAssetsToAlbumAsync, how do I get the reference as filepath or id, after saving it?

I saw in a post that it is also not possible to change the filename.

You get the asset ID by calling createAssetAsync first, then saving it- https://docs.expo.dev/versions/v42.0.0/sdk/media-library/#medialibrarycreateassetasynclocaluri

1 Like

const asset = await MediaLibrary.createAssetAsync(result.uri)
console.log("ASSET: ", asset.id);
ASSET: 75481

To insert in album:
const value = await MediaLibrary.addAssetsToAlbumAsync([asset], album, false)
When i list all asserts, I noticed it has a different id

{{…, id: “75482” … }}
ASSET INSERTED IN ALBUM: 75482

Maybe the same asset in different albums corresponds to a different ID?

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