<commit_before>---
title: MediaLibrary
---

Provides access to user's media library.

Requires `Permissions.CAMERA_ROLL` permissions.

## Methods

### `Expo.MediaLibrary.createAssetAsync(localUri)`

Creates an asset from existing file. The most common use case is to save a picture taken by [Camera](./camera.html).

```
const { uri } = await camera.takePictureAsync();
const asset = await MediaLibrary.createAssetAsync(uri);
```

#### Arguments

-   **localUri (_string_)** -- A URI to the image or video file. On Android it must be a local path, so it must start with `file:///`.

#### Returns

An object representing an [asset](#asset).

### `Expo.MediaLibrary.getAssetsAsync(options)`

Fetches a page of assets matching the provided criteria.

#### Arguments
-   **options (_object_)**

    -   **first (_number_)** -- The maximum number of items on a single page.
    -   **after (_string_)** -- Asset ID of the last item returned on the previous page.
    -   **album (_string_ | _Album_)** -- [Album](#album) or its ID to get assets from specific album.
    -   **sortBy (_array_)** -- An array of [SortBy](#expomedialibrarysortby) 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.
    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](#expomedialibrarymediatype) types.

#### Returns<commit_msg>[sdk] MediaLibrary getAssets default value of mediaType; MediaLibrary test modification (#2843)<commit_after>---
title: MediaLibrary
---

Provides access to user's media library.

Requires `Permissions.CAMERA_ROLL` permissions.

## Methods

### `Expo.MediaLibrary.createAssetAsync(localUri)`

Creates an asset from existing file. The most common use case is to save a picture taken by [Camera](./camera.html).

```
const { uri } = await camera.takePictureAsync();
const asset = await MediaLibrary.createAssetAsync(uri);
```

#### Arguments

-   **localUri (_string_)** -- A URI to the image or video file. On Android it must be a local path, so it must start with `file:///`.

#### Returns

An object representing an [asset](#asset).

### `Expo.MediaLibrary.getAssetsAsync(options)`

Fetches a page of assets matching the provided criteria.

#### Arguments
-   **options (_object_)**

    -   **first (_number_)** -- The maximum number of items on a single page.
    -   **after (_string_)** -- Asset ID of the last item returned on the previous page.
    -   **album (_string_ | _Album_)** -- [Album](#album) or its ID to get assets from specific album.
    -   **sortBy (_array_)** -- An array of [SortBy](#expomedialibrarysortby) 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.
    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](#expomedialibrarymediatype) types. By default `MediaType.photo` is set.

#### Returns
{'fraction_non_alphanumeric': 0.11657722122838401, 'fraction_numerical': 0.0011926058437686344, 'mean_word_length': 3.8412698412698414, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7549658', 'n_tokens_mistral': 963, 'n_tokens_neox': 920, 'n_words': 404}