提交 dbea77a9 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 f8e684f9
......@@ -903,7 +903,7 @@ async function example() {
deleteAssets(uriList: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void;
Deletes media files. This API uses an asynchronous callback to return the result. The deleted files are moved to the recycle bin.
Deletes media files. This API uses an asynchronous callback to return the result. The deleted files are moved to the trash.
**System API**: This is a system API.
......@@ -964,7 +964,7 @@ async function example() {
deleteAssets(uriList: Array&lt;string&gt;): Promise&lt;void&gt;;
Deletes media files. This API uses a promise to return the result. The deleted files are moved to the recycle bin.
Deletes media files. This API uses a promise to return the result. The deleted files are moved to the trash.
**System API**: This is a system API.
......@@ -1159,7 +1159,7 @@ async function example() {
createDeleteRequest(uriList: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void;
Creates a dialog box for deleting photos. This API uses an asynchronous callback to return the result. The deleted photos are moved to the recycle bin.
Creates a dialog box for deleting photos. This API uses an asynchronous callback to return the result. The deleted photos are moved to the trash.
**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
......@@ -1217,7 +1217,7 @@ async function example() {
createDeleteRequest(uriList: Array&lt;string&gt;): Promise&lt;void&gt;;
Creates a dialog box for deleting photos. This API uses a promise to return the result. The deleted photos are moved to the recycle bin.
Creates a dialog box for deleting photos. This API uses a promise to return the result. The deleted photos are moved to the trash.
**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
......@@ -3258,7 +3258,7 @@ async function example() {
recoverAssets(assets: Array&lt;PhotoAsset&gt;, callback: AsyncCallback&lt;void&gt;): void;
Recovers image or video assets from the recycle bin. Before the operation, ensure that the image or video assets exist in the recycle bin. This API uses an asynchronous callback to return the result.
Recovers image or video assets from the trash. Before the operation, ensure that the image or video assets exist in the trash. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
......@@ -3316,7 +3316,7 @@ async function example() {
recoverAssets(assets: Array&lt;PhotoAsset&gt;): Promise&lt;void&gt;;
Recovers image or video assets from the recycle bin. Before the operation, ensure that the image or video assets exist in the recycle bin. This API uses a promise to return the result.
Recovers image or video assets from the trash. Before the operation, ensure that the image or video assets exist in the trash. This API uses a promise to return the result.
**System API**: This is a system API.
......@@ -3377,7 +3377,7 @@ async function example() {
deleteAssets(assets: Array&lt;PhotoAsset&gt;, callback: AsyncCallback&lt;void&gt;): void;
Deletes image or video assets from the recycle bin. Before the operation, ensure that the image or video assets exist in the recycle bin. This API uses an asynchronous callback to return the result.
Deletes image or video assets from the trash. Before the operation, ensure that the image or video assets exist in the trash. This API uses an asynchronous callback to return the result.
**CAUTION**<br>This operation is irreversible. The file assets deleted cannot be restored. Exercise caution when performing this operation.
......@@ -3437,7 +3437,7 @@ async function example() {
deleteAssets(assets: Array&lt;PhotoAsset&gt;): Promise&lt;void&gt;;
Deletes image or video assets from the recycle bin. Before the operation, ensure that the image or video assets exist in the recycle bin. This API uses a promise to return the result.
Deletes image or video assets from the trash. Before the operation, ensure that the image or video assets exist in the trash. This API uses a promise to return the result.
**CAUTION**<br>This operation is irreversible. The file assets deleted cannot be restored. Exercise caution when performing this operation.
......@@ -3568,7 +3568,7 @@ Enumerate the album subtypes.
| FAVORITE | 1025 | Favorites.|
| VIDEO | 1026 | Video album.|
| HIDDEN | 1027 | Hidden album. **System API**: This is a system API.|
| TRASH | 1028 | Recycle bin. **System API**: This is a system API.|
| TRASH | 1028 | Trash. **System API**: This is a system API.|
| SCREENSHOT | 1029 | Album for screenshots and screen recording files. **System API**: This is a system API.|
| CAMERA | 1030 | Album for photos and videos taken by the camera. **System API**: This is a system API.|
| ANY | 2147483647 | Any album.|
......
# File Subsystem Changelog
## cl.file.1 Change of the mediaLibrary Interface Compatibility
Changed the compatibility of some **mediaLibrary** APIs.
**Change Impact**
The compatibility of some [mediaLibrary](../../../application-dev/reference/apis/js-apis-medialibrary.md) APIs is changed.
For applications developed based on earlier versions, pay attention to the iterative update of deprecated APIs.
**Key API/Component Changes**
| Module | Method/Attribute/Enum/Constant | Change Type|
| ------------------------- | ------------------------------------------------------------ | -------- |
| medialibrary | **function** getFileAssets(options: MediaFetchOptions, callback: AsyncCallback&lt;FetchFileResult&gt;): void | Interface compatibility changed |
| medialibrary | **function** getFileAssets(options: MediaFetchOptions): Promise&lt;FetchFileResult&gt; | Interface compatibility changed |
| medialibrary | **function** createAsset(mediaType: MediaType, displayName: string, relativePath: string, callback: AsyncCallback&lt;FileAsset&gt;): void| Interface compatibility changed |
| medialibrary | **function** createAsset(mediaType: MediaType, displayName: string, relativePath: string): Promise&lt;FileAsset&gt;| Interface compatibility changed |
| medialibrary | **function** getAlbums(options: MediaFetchOptions, callback: AsyncCallback&lt;Array&lt;Album&gt;&gt;): void | Interface compatibility changed |
| medialibrary | **function** getAlbums(options: MediaFetchOptions): Promise&lt;Array&lt;Album&gt;&gt; | Interface compatibility changed |
| medialibrary | **function** FileAsset.commitModify(callback: AsyncCallback&lt;void&gt;): void | Interface compatibility changed |
| medialibrary | **function** FileAsset.commitModify(): Promise&lt;void&gt; | Interface compatibility changed |
**Adaptation Guide**
**getFileAssets**
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:
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.
**Incorrect code example**:
```js
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
async function example() {
try {
let context = getContext(this);
let media = mediaLibrary.getMediaLibrary(context);
let fileKeyObj = mediaLibrary.FileKey;
let albumId = 1;
let getImageOp = {
selections: fileKeyObj.ALBUM_ID + '= ?', // File assets cannot be obtained based on the parent, albumId, albumUri, and albumName attributes.
selectionArgs: [albumId.toString()],
};
const fetchFileResult = await media.getFileAssets(getImageOp); // The obtained fetchFileResult is empty.
const fileAsset = await fetchFileResult.getFirstObject();
console.info('mediaLibrary fileAsset displayName: ' + fileAsset.displayName);
} catch (err) {
console.error('mediaLibrary fail, err: ' + err);
}
}
```
Use **getFileAssets()** as follows:
**Correct code example**:
```js
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
async function example() {
try {
let context = getContext(this);
let media = mediaLibrary.getMediaLibrary(context);
let fileKeyObj = mediaLibrary.FileKey;
let imageType = mediaLibrary.MediaType.IMAGE;
let getImageOp = {
selections: fileKeyObj.MEDIA_TYPE + '= ?',
selectionArgs: [imageType.toString()], // Query all files of the image type.
};
const fetchFileResult = await media.getFileAssets(getImageOp);
const fileAsset = await fetchFileResult.getFirstObject();
console.info('mediaLibrary fileAsset displayName: ' + fileAsset.displayName);
} catch (err) {
console.error('mediaLibrary fail, err: ' + err);
}
}
```
**createAsset**
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.
**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:
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.
**Incorrect code example**:
```js
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
async function example() {
try {
let context = getContext(this);
let media = mediaLibrary.getMediaLibrary(context);
let AlbumNoArgsfetchOp = {
selections: mediaLibrary.FileKey.ALBUM_NAME + ' = ?',
selectionArgs:['New album 1'], //Obtain the album named New album 1.
};
const albumList = await media.getAlbums(AlbumNoArgsfetchOp); // The fetchFileResult returned is empty.
for (let i = 0; i < albumList.length; i++) {
console.info('mediaLibrary album albumName: ' + albumList[i].albumName);
}
} catch (err) {
console.error('mediaLibrary fail, err: ' + err);
}
}
```
The following example shows how to obtain **Camera** and **Screenshots** albums:
**Correct code example**:
```js
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
async function example() {
try {
let context = getContext(this);
let media = mediaLibrary.getMediaLibrary(context);
let AlbumNoArgsfetchOp = {
selections: mediaLibrary.FileKey.ALBUM_NAME + ' = ? OR ' + mediaLibrary.FileKey.ALBUM_NAME + ' = ?',
selectionArgs: ['Camera', 'Screenshots'], // Obtain the camera and screenshot albums.
};
const albumList = await media.getAlbums(AlbumNoArgsfetchOp);
for (let i = 0; i < albumList.length; i++) {
console.info('mediaLibrary album albumName: ' + albumList[i].albumName);
}
} catch (err) {
console.error('mediaLibrary fail, err: ' + err);
}
}
```
**FileAsset.commitModify**
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.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册