@@ -88,8 +88,8 @@ Obtains file assets (also called files). This API uses an asynchronous callback
> **NOTE**
>
> - This API is deprecated since API Version 9. Use [getAssets](js-apis-photoAccessHelper.md#getassets) instead.
> - From API version 10, the albums represented by physical directories are replaced by logical albums, which allows multiple files in an album and presence of a file in multiple albums. This design, however, makes **parent**, **albumId**, **albumUri**, and **albumName** incompatible. They cannot be used as parameters of **MediaFetchOptions** in **getFileAssets()**. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
> - This API is deprecated since API version 9. Use [getAssets](js-apis-photoAccessHelper.md#getassets) instead.
> - From API version 10, the albums represented by physical directories are replaced by logical albums, which allow multiple files in an album and presence of a file in multiple albums. This design, however, makes **parent**, **albumId**, **albumUri**, and **albumName** incompatible. They cannot be used as parameters of **MediaFetchOptions** in **getFileAssets()**. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
@@ -161,8 +161,8 @@ Obtains file assets. This API uses a promise to return the result.
> **NOTE**
>
> - This API is deprecated since API Version 9. Use [getAssets](js-apis-photoAccessHelper.md#getassets-1) instead.
> - From API version 10, the albums represented by physical directories are replaced by logical albums, which allows multiple files in an album and presence of a file in multiple albums. This design, however, makes **parent**, **albumId**, **albumUri**, and **albumName** incompatible. They cannot be used as parameters of **MediaFetchOptions** in **getFileAssets()**. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
> - This API is deprecated since API version 9. Use [getAssets](js-apis-photoAccessHelper.md#getassets-1) instead.
> - From API version 10, the albums represented by physical directories are replaced by logical albums, which allow multiple files in an album and presence of a file in multiple albums. This design, however, makes **parent**, **albumId**, **albumUri**, and **albumName** incompatible. They cannot be used as parameters of **MediaFetchOptions** in **getFileAssets()**. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
@@ -287,7 +289,7 @@ Creates a media asset. This API uses an asynchronous callback to return the resu
> **NOTE**
>
> - This API is deprecated since API Version 9. Use [createAsset](js-apis-photoAccessHelper.md#createasset) instead.
> - This API is deprecated since API version 9. Use [createAsset](js-apis-photoAccessHelper.md#createasset) instead.
> - From the SDK of API version 10, **relativePath** is no longer associated with an album. After a file is created, the last-level directory of **relativePath** is not displayed. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
...
...
@@ -329,7 +331,7 @@ Creates a media asset. This API uses a promise to return the result.
> **NOTE**
>
> - This API is deprecated since API Version 9. Use [createAsset](js-apis-photoAccessHelper.md#createasset-1) instead.
> - This API is deprecated since API version 9. Use [createAsset](js-apis-photoAccessHelper.md#createasset-1) instead.
> - From the SDK of API version 10, **relativePath** is no longer associated with an album. After a file is created, the last-level directory of **relativePath** is not displayed. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
...
...
@@ -375,7 +377,8 @@ Deletes a file asset. This API uses a promise to return the result.
Before calling this API, call [FileAsset.trash](#trash8) to move the file to the trash. Otherwise, the file fails to be deleted.
> **NOTE**
> This API is deprecated since API Version 9. Use [deleteAssets](js-apis-photoAccessHelper.md#deleteassets-3) instead.
>
> This API is deprecated since API version 9. Use [deleteAssets](js-apis-photoAccessHelper.md#deleteassets-3) instead.
**System API**: This is a system API.
...
...
@@ -429,7 +432,8 @@ Deletes a file asset. This API uses an asynchronous callback to return the resul
Before calling this API, call [FileAsset.trash](#trash8) to move the file to the trash. Otherwise, the file fails to be deleted.
> **NOTE**
> This API is deprecated since API Version 9. Use [deleteAssets](js-apis-photoAccessHelper.md#deleteassets-2) instead.
>
> This API is deprecated since API version 9. Use [deleteAssets](js-apis-photoAccessHelper.md#deleteassets-2) instead.
@@ -550,7 +556,7 @@ Obtains albums. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> - This API is deprecated since API Version 9. Use [getAlbums](js-apis-photoAccessHelper.md#getalbums) instead.
> - This API is deprecated since API version 9. Use [getAlbums](js-apis-photoAccessHelper.md#getalbums) instead.
> - From the SDK of API version 10, **relativePath** is no longer associated with an album. Therefore, **relativePath** cannot be used as a search criterion in **getAlbums**. Currently, only **Camera** and **ScreenShots** albums are supported. For more details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
@@ -590,7 +596,7 @@ Obtains albums. This API uses a promise to return the result.
> **NOTE**
>
> - This API is deprecated since API Version 9. Use [getAlbums](js-apis-photoAccessHelper.md#getalbums-2) instead.
> - This API is deprecated since API version 9. Use [getAlbums](js-apis-photoAccessHelper.md#getalbums-2) instead.
> - From the SDK of API version 10, **relativePath** is no longer associated with an album. Therefore, **relativePath** cannot be used as a search criterion in **getAlbums**. Currently, only **Camera** and **ScreenShots** albums are supported. For more details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the result.
Starts image preview, with the first image to preview specified. This API can be used to preview a local image with the specified index (**file://**) or all online images (**https://**). It uses an asynchronous callback to return the result.
> **NOTE**
>
> - This API is supported since API version 6 and can be used only in the FA model.
> - This API is deprecated since API Version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. <br>The **\<Image>** component can be used to render and display local and online images.
> - This API is deprecated since API version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. <br>The **\<Image>** component can be used to render and display local and online images.
Starts image preview. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses an asynchronous callback to return the result.
Starts image preview. This API can be used to preview the first local image (**file://**) or all online images (**https://**). It uses an asynchronous callback to return the result.
> **NOTE**
>
> - This API is supported since API version 6 and can be used only in the FA model.
> - This API is deprecated since API Version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. <br>The **\<Image>** component can be used to render and display local and online images.
> - This API is deprecated since API version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. <br>The **\<Image>** component can be used to render and display local and online images.
Starts image preview, with the first image to preview specified. This API can be used to preview local images whose URIs start with **datashare://** or online images whose URIs start with **https://**. It uses a promise to return the execution result.
Starts image preview, with the first image to preview specified. This API can be used to preview a local image with the specified index (**file://**) or all online images (**https://**). It uses a promise to return the execution result.
> **NOTE**
>
> - This API is supported since API version 6 and can be used only in the FA model.
> - This API is deprecated since API Version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. <br>The **\<Image>** component can be used to render and display local and online images.
> - This API is deprecated since API version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. <br>The **\<Image>** component can be used to render and display local and online images.
> - The system attempts to parse the file content if the file is an audio or video file. The actual field values will be restored from the passed values during scanning on some devices.
> - Some devices may not support the modification of **orientation**. You are advised to use [ModifyImageProperty](js-apis-image.md#modifyimageproperty9) of the **image** module.
> - This API is deprecated since API Version 9. Use [PhotoAsset](js-apis-photoAccessHelper.md#photoasset) instead.
> - This API is deprecated since API version 9. Use [PhotoAsset](js-apis-photoAccessHelper.md#photoasset) instead.
@@ -1238,7 +1251,7 @@ Commits the modification on the file metadata to the database. This API uses an
> **NOTE**
>
> - This API is deprecated since API Version 9. Use [commitModify](js-apis-photoAccessHelper.md#commitmodify) instead.
> - This API is deprecated since API version 9. Use [commitModify](js-apis-photoAccessHelper.md#commitmodify) instead.
> - Since the SDK of API version 10, **audio** does not have the **orientation** attribute. Therefore, the **orientation** attribute of the audio resource cannot be modified by **commitModify()**. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
...
...
@@ -1280,7 +1293,7 @@ Commits the modification on the file asset to the database. This API uses a prom
> **NOTE**
>
> - This API is deprecated since API Version 9. Use [commitModify](js-apis-photoAccessHelper.md#commitmodify-1) instead.
> - This API is deprecated since API version 9. Use [commitModify](js-apis-photoAccessHelper.md#commitmodify-1) instead.
> Since the SDK of API version 10, **audio** does not have the **orientation** attribute. Therefore, the **orientation** attribute of the audio resource cannot be modified by **commitModify()**. For details, see [changelogs-mediaLibrary.md](../../../release-notes/changelogs/OpenHarmony_4.0.8.2/changelogs-mediaLibrary.md).
**Required permissions**: ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA
Opens this file asset. This API uses an asynchronous callback to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [open](js-apis-photoAccessHelper.md#open) instead.
**NOTE**<br>If a file is opened in 'w' mode, the returned file descriptor (FD) cannot be used to read the file. However, due to the implementation differences of file systems, some user-mode files opened in 'w' mode can be read by using FD. To perform the read or write operation on a file by using FD, you are advised to open the file in 'rw' mode. The write operations are mutually exclusive. After a write operation is complete, you must call **close** to close the file.
>
> - This API is deprecated since API version 9. Use [open](js-apis-photoAccessHelper.md#open) instead.
>
> - If a file is opened in 'w' mode, the returned file descriptor (FD) cannot be used to read the file. However, due to the implementation differences of file systems, some user-mode files opened in 'w' mode can be read by using FD. To perform the read or write operation on a file by using FD, you are advised to open the file in 'rw' mode.
> - The write operations are mutually exclusive. After a write operation is complete, you must call **close** to close the file.
**Required permissions**: ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA
Opens this file asset. This API uses a promise to return the result.
> **NOTE**
> This API is deprecated since API Version 9. Use [open](js-apis-photoAccessHelper.md#open-1) instead.
**NOTE**<br>If a file is opened in 'w' mode, the returned FD cannot be used to read the file. However, due to the implementation differences of file systems, some user-mode files opened in 'w' mode can be read by using FD. To perform the read or write operation on a file by using FD, you are advised to open the file in 'rw' mode. The write operations are mutually exclusive. After a write operation is complete, you must call **close** to close the file.
>
> - This API is deprecated since API version 9. Use [open](js-apis-photoAccessHelper.md#open-1) instead.
> - If a file is opened in 'w' mode, the returned FD cannot be used to read the file. However, due to the implementation differences of file systems, some user-mode files opened in 'w' mode can be read by using FD. To perform the read or write operation on a file by using FD, you are advised to open the file in 'rw' mode.
> - The write operations are mutually exclusive. After a write operation is complete, you must call **close** to close the file.
**Required permissions**: ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA
@@ -2185,7 +2220,7 @@ Obtains the next file asset in the result set. This API uses an asynchronous cal
> **NOTE**
>
> - Before using this API, you must use [getFirstObject](#getfirstobject7) to obtain the first file asset and then use [isAfterLast](#isafterlast7) to check that the cursor does not point to the last file asset in the result set.
> - This API is deprecated since API Version 9. Use [getNextObject](js-apis-photoAccessHelper.md#getnextobject) instead.
> - This API is deprecated since API version 9. Use [getNextObject](js-apis-photoAccessHelper.md#getnextobject) instead.
@@ -2232,7 +2267,7 @@ Obtains the next file asset in the result set. This API uses a promise to return
> **NOTE**
>
> - Before using this API, you must use [getFirstObject](#getfirstobject7) to obtain the first file asset and then use [isAfterLast](#isafterlast7) to check that the cursor does not point to the last file asset in the result set.
> - This API is deprecated since API Version 9. Use [getNextObject](js-apis-photoAccessHelper.md#getnextobject-1) instead.
> - This API is deprecated since API version 9. Use [getNextObject](js-apis-photoAccessHelper.md#getnextobject-1) instead.
| selections | string | Yes | Yes | Conditions for fetching files. The enumerated values in [FileKey](#filekey8) are used as the column names when files are fetched. Example:<br>selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR ' + mediaLibrary.FileKey.MEDIA_TYPE + '= ?', |
| selections | string | Yes | Yes | Conditions for fetching files. The enumerated values in [FileKey](#filekey8) are used as the column names when files are fetched. <br/>Example:<br>selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR ' + mediaLibrary.FileKey.MEDIA_TYPE + '= ?', |
| selectionArgs | Array<string> | Yes | Yes | Values of the conditions specified in **selections**.<br>Example:<br>selectionArgs: [mediaLibrary.MediaType.IMAGE.toString(), mediaLibrary.MediaType.VIDEO.toString()], |
| order | string | Yes | Yes | Sorting mode of the search results, which can be ascending or descending. The enumerated values in [FileKey](#filekey8) are used as the columns for sorting the search results. Example:<br>Ascending: order: mediaLibrary.FileKey.DATE_ADDED + ' ASC'<br>Descending: order: mediaLibrary.FileKey.DATE_ADDED + ' DESC'|
| order | string | Yes | Yes | Sorting mode of the search results, which can be ascending or descending. The enumerated values in [FileKey](#filekey8) are used as the columns for sorting the search results. <br/>Example:<br>Ascending: order: mediaLibrary.FileKey.DATE_ADDED + ' ASC'<br>Descending: order: mediaLibrary.FileKey.DATE_ADDED + ' DESC' |
| uri<sup>8+</sup> | string | Yes | Yes | URI of the file. |
| networkId<sup>8+</sup> | string | Yes | Yes | Network ID of the registered device. |
| extendArgs<sup>8+</sup> | string | Yes | Yes | Extended parameters for fetching the files. Currently, no extended parameters are available. |
...
...
@@ -2887,7 +2939,8 @@ Defines the options for fetching media files.
Defines the image size.
> **NOTE**
> This API is deprecated since API Version 9. Use [image.Size](js-apis-image.md#size) instead.
>
> This API is deprecated since API version 9. Use [image.Size](js-apis-image.md#size) instead.
| src | string | Yes | Yes | Application sandbox oath of the local file. |
| mimeType | string | Yes | Yes | Multipurpose Internet Mail Extensions (MIME) type of the media.<br>The value can be 'image/\*', 'video/\*', 'audio/\*' or 'file\*'.|
| relativePath | string | Yes | Yes | Custom path of media assets, for example, **Pictures/**. If this parameter is unspecified, media assets are stored in the default path.<br> Default path of images: **'Pictures/'**<br> Default path of videos: **'Videos/'**<br> Default path of audios: **'Audios/'**<br> Default path of documents: **'Documents/'**|
| mimeType | string | Yes | Yes | Multipurpose Internet Mail Extensions (MIME) type of the media.<br>The value can be 'image/\*', 'video/\*', 'audio/\*' or 'file/*'. |
| relativePath | string | Yes | Yes | Customized path of media assets, for example, **Pictures/**. If this parameter is unspecified, the default paths of media assets are as follows:<br> Default path of images: **'Pictures/'**<br> Default path of videos: **'Videos/'**<br> Default path of audio files: **'Audios/'**<br> Default path of documents: **'Documents/'**|
## MediaSelectOption
Defines the media selection option.
> **NOTE**
> This API is deprecated since API Version 9. There is no substitute API.
>
> This API is deprecated since API version 9. There is no substitute API.
| type | 'image' | 'video' | 'media' | Yes | Yes | Media type, which can be **image**, **media**, or **video**. Currently, only **media** is supported.|
| count | number | Yes | Yes | Maximum number of media assets that can be selected. The value starts from 1, which indicates that one media asset can be selected. |
| count | number | Yes | Yes | Maximum number of media assets that can be selected.<br/>The value **1** means to select only one media asset; the value greater than **1** means to select multiple media assets. |
From API version 10, the albums represented by physical directories are replaced by logical albums, which allows multiple files in an album and presence of a file in multiple albums. This design, however, makes **parent**, **albumId**, **albumUri**, and **albumName** incompatible. They cannot be used as parameters of **MediaFetchOptions** in **getFileAssets()**. See the following example:
From API version 10, the albums represented by physical directories are replaced by logical albums, which allow multiple files in an album and presence of a file in multiple albums. This design, however, makes **parent**, **albumId**, **albumUri**, and **albumName** incompatible. They cannot be used as parameters of **MediaFetchOptions** in **getFileAssets()**. The following is an example of incorrect use of the APIs.
1.Use[getMediaLibrary](../../../application-dev/reference/apis/js-apis-medialibrary.md#medialibrarygetmedialibrary) to obtain a **MediaLibrary** instance.
2.Use[MediaFetchOptions](../../../application-dev/reference/apis/js-apis-medialibrary.md#mediafetchoptions7) to create the file fetching options.
3.Use[getFileAssets](../../../application-dev/reference/apis/js-apis-medialibrary.md#getfileassets7) to obtain file assets.
1.Call[getMediaLibrary](../../../application-dev/reference/apis/js-apis-medialibrary.md#medialibrarygetmedialibrary) to obtain a **MediaLibrary** instance.
2.Call[MediaFetchOptions](../../../application-dev/reference/apis/js-apis-medialibrary.md#mediafetchoptions7) to create the file fetching options.
3.Call[getFileAssets](../../../application-dev/reference/apis/js-apis-medialibrary.md#getfileassets7) to obtain file assets.
From the SDK of API version 10, **relativePath** is no longer associated with an album. After a file is created, the last-level directory of **relativePath** is not displayed as an album.
Since the SDK of API version 10, **relativePath** is no longer associated with an album. After a file is created, the last-level directory of **relativePath** is not displayed as an album.
**getAlbums**
From the SDK of API version 10, **relativePath** is no longer associated with an album. Therefore, **relativePath** cannot be used as a search criterion in **getAlbums**, and the values of **ALBUM_NAME** can be **Camera** and **Screenshots** only. See the following example:
Since the SDK of API version 10, **relativePath** is no longer associated with an album. Therefore, **relativePath** cannot be used as a search criterion in **getAlbums**, and the values of **ALBUM_NAME** can be **Camera** and **Screenshots** only. The following is an example of incorrect use of the APIs.
1. Use [getMediaLibrary](../../../application-dev/reference/apis/js-apis-medialibrary.md#medialibrarygetmedialibrary) to obtain a **MediaLibrary** instance.
2. Use [MediaFetchOptions](../../../application-dev/reference/apis/js-apis-medialibrary.md#mediafetchoptions7) to create the album fetching options.
3. Use [getAlbums](../../../application-dev/reference/apis/js-apis-medialibrary.md#getalbums7) to obtain albums.
The **orientation** attribute for audio is deleted from the SDK of API version 10. When **commitModify** is used, the **orientation** attribute of audio resources cannot be modified.
**FileAsset.deleteAsset**
The change has resolved a known issue of the file deletion mechanism. This issue may cause a system application to permanently delete a file that is not in the trash using **MediaLibrary.deleteAsset**.
The correct procedure for a system application to permanently delete a file is as follows:
1. Call [getFileAssets](../../../application-dev/reference/apis/js-apis-medialibrary.md#getfileassets7) to obtain file assets.
2. Call [FileAsset.trash](../../../application-dev/reference/apis/js-apis-medialibrary.md#trash8) to move the file to the trash.
3. Call [MediaLibrary.deleteAsset](../../../application-dev/reference/apis/js-apis-medialibrary.md#deleteasset8) to permanently delete the file.