expo-media-library provides access to the user's media library, allowing them to access their existing images and videos from your app, as well as save new ones. You can also subscribe to any updates made to the user's media library.
localUri (string) -- A URI to the image or video file. It must contain an extension. On Android it must be a local path, so it must start with file:///.
Saves the file at given localUri to the user's media library. Unlike createAssetAsync(), this method doesn't return created asset.
On iOS 11+, it's possible to use this method without asking for CAMERA_ROLL permission, however then yours Info.plist should have NSPhotoLibraryAddUsageDescription key.
localUri (string) -- A URI to the image or video file. It must contain an extension. On Android it must be a local path, so it must start with file:///.
first (number) -- The maximum number of items on a single page. Defaults to 20.
after (string) -- Asset ID of the last item returned on the previous page.
album (string | Album) -- Album or its ID to get assets from specific album.
sortBy (array) -- An array of SortBy keys. By default, all keys are sorted in descending order, however you can also pass a pair [key, ascending] where the second item is a boolean value that means whether to use ascending order. Note that if the SortBy.default key is used, then ascending argument will not matter.
Earlier items have higher priority when sorting out the results.
If empty, this method will use the default sorting that is provided by the platform.
mediaType (array) -- An array of MediaType types. By default MediaType.photo is set.
createdAfter (Date | number) -- Date object or Unix timestamp in milliseconds limiting returned assets only to those that were created after this date.
createdBefore (Date | number) -- Similarly as createdAfter, but limits assets only to those that were created before specified date.
shouldDownloadFromNetwork (boolean) -- Whether allow the asset to be downloaded from network. Only available in iOS with iCloud assets. Defaults to true.
Deletes assets from the library.
On iOS it deletes assets from all albums they belong to, while on Android it keeps all copies of them (album is strictly connected to the asset).
Also, there is additional dialog on iOS that requires user to confirm this action.
Creates an album with given name and initial asset.
The asset parameter is required on Android, since it's not possible to create empty album on this platform.
On Android, by default it copies given asset from the current album to the new one, however it's also possible to move it by passing false as copyAsset argument.
In case it's copied you should keep in mind that getAssetsAsync will return duplicated asset.
On Android by default it deletes assets belonging to given albums from the library. On iOS it doesn't delete these assets, however it's possible to do by passing true as deleteAssets.
On Android, by default it copies assets from the current album to provided one, however it's also possible to move them by passing false as copyAssets argument.
In case they're copied you should keep in mind that getAssetsAsync will return duplicated assets.
listener (function) -- A callback that is called when any assets have been inserted or deleted from the library. On Android it's invoked with an empty object. On iOS it's invoked with an object that contains following keys:
insertedAssets (array) -- Array of assets that have been inserted to the library.
deletedAssets (array) -- Array of assets that have been deleted from the library.
updatedAssets (array) -- Array of assets that have been updated or completed downloading from network storage (iCloud in iOS).
MediaLibrary.CameraRollPermissionResponse extends PermissionResponse type exported by unimodules-permission-interface and contains additional iOS-specific field:
accessPrivileges(string) - Indicates if your app has access to the whole or only part of the photo library. Possible values are:
all if the user granted your app access to the whole photo library
limited if the user granted your app access only to selected photos (only available on iOS 14.0+)
none if user denied or hasn't yet granted the permission