1# @ohos.file.photoAccessHelper (Album Management) (System API) 2 3The **photoAccessHelper** module provides APIs for album management, including creating an album and accessing and modifying media data in an album. 4 5> **NOTE** 6> 7> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8> - This topic describes only the system APIs provided by the module. For details about its public APIs, see [@ohos.file.photoAccessHelper (Album Management)](js-apis-photoAccessHelper.md). 9 10## Modules to Import 11 12```ts 13import { photoAccessHelper } from '@kit.MediaLibraryKit'; 14``` 15 16## PhotoAccessHelper 17 18### createAsset 19 20createAsset(displayName: string, callback: AsyncCallback<PhotoAsset>): void 21 22Creates an image or video asset with the specified file name. This API uses an asynchronous callback to return the result. 23 24The file name must comply with the following specifications: 25- The file name consists of a valid file name and an image or video file name extension. 26- The file name cannot exceed 255 characters. 27- The file name cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ] 28 29**System API**: This is a system API. 30 31**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 32 33**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 34 35**Parameters** 36 37| Name | Type | Mandatory| Description | 38| -------- | ------------------------ | ---- | ------------------------- | 39| displayName | string | Yes | File name of the image or video to create. | 40| callback | AsyncCallback<[PhotoAsset](#photoasset)> | Yes | Callback used to return the image or video created.| 41 42**Error codes** 43 44For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 45 46| ID| Error Message| 47| -------- | ---------------------------------------- | 48| 202 | Called by non-system application. | 49| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 50| 13900012 | Permission denied. | 51| 13900020 | Invalid argument. | 52| 14000001 | Invalid display name. | 53| 14000011 | System inner fail. | 54 55**Example** 56 57```ts 58async function example() { 59 console.info('createAssetDemo'); 60 let testFileName: string = 'testFile' + Date.now() + '.jpg'; 61 phAccessHelper.createAsset(testFileName, (err, photoAsset) => { 62 if (photoAsset !== undefined) { 63 console.info('createAsset file displayName' + photoAsset.displayName); 64 console.info('createAsset successfully'); 65 } else { 66 console.error(`createAsset failed, error: ${err.code}, ${err.message}`); 67 } 68 }); 69} 70``` 71 72### createAsset 73 74createAsset(displayName: string): Promise<PhotoAsset> 75 76Creates an image or video asset with the specified file name. This API uses a promise to return the result. 77 78The file name must comply with the following specifications: 79- The file name consists of a valid file name and an image or video file name extension. 80- The file name cannot exceed 255 characters. 81- The file name cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ] 82 83**System API**: This is a system API. 84 85**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 86 87**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 88 89**Parameters** 90 91| Name | Type | Mandatory| Description | 92| -------- | ------------------------ | ---- | ------------------------- | 93| displayName | string | Yes | File name of the image or video to create. | 94 95**Return value** 96 97| Type | Description | 98| --------------------------- | -------------- | 99| Promise<[PhotoAsset](#photoasset)> | Promise used to return the created image and video asset.| 100 101**Error codes** 102 103For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 104 105| ID| Error Message| 106| -------- | ---------------------------------------- | 107| 202 | Called by non-system application. | 108| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 109| 13900012 | Permission denied. | 110| 13900020 | Invalid argument. | 111| 14000001 | Invalid display name. | 112| 14000011 | System inner fail. | 113 114**Example** 115 116```ts 117async function example() { 118 console.info('createAssetDemo'); 119 try { 120 let testFileName: string = 'testFile' + Date.now() + '.jpg'; 121 let photoAsset: photoAccessHelper.PhotoAsset = await phAccessHelper.createAsset(testFileName); 122 console.info('createAsset file displayName' + photoAsset.displayName); 123 console.info('createAsset successfully'); 124 } catch (err) { 125 console.error(`createAsset failed, error: ${err.code}, ${err.message}`); 126 } 127} 128``` 129 130### createAsset 131 132createAsset(displayName: string, options: PhotoCreateOptions, callback: AsyncCallback<PhotoAsset>): void 133 134Creates an image or video asset with the specified file name and options. This API uses an asynchronous callback to return the result. 135 136The file name must comply with the following specifications: 137- The file name consists of a valid file name and an image or video file name extension. 138- The file name cannot exceed 255 characters. 139- The file name cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ] 140 141**System API**: This is a system API. 142 143**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 144 145**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 146 147**Parameters** 148 149| Name | Type | Mandatory| Description | 150| -------- | ------------------------ | ---- | ------------------------- | 151| displayName | string | Yes | File name of the image or video to create. | 152| options | [PhotoCreateOptions](#photocreateoptions) | Yes | Options for creating an image or video asset. | 153| callback | AsyncCallback<[PhotoAsset](#photoasset)> | Yes | Callback used to return the image or video created.| 154 155**Error codes** 156 157For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 158 159| ID| Error Message| 160| -------- | ---------------------------------------- | 161| 202 | Called by non-system application. | 162| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 163| 13900012 | Permission denied. | 164| 13900020 | Invalid argument. | 165| 14000001 | Invalid display name. | 166| 14000011 | System inner fail. | 167 168**Example** 169 170```ts 171async function example() { 172 console.info('createAssetDemo'); 173 let testFileName: string = 'testFile' + Date.now() + '.jpg'; 174 let createOption: photoAccessHelper.PhotoCreateOptions = { 175 subtype: photoAccessHelper.PhotoSubtype.DEFAULT 176 } 177 phAccessHelper.createAsset(testFileName, createOption, (err, photoAsset) => { 178 if (photoAsset !== undefined) { 179 console.info('createAsset file displayName' + photoAsset.displayName); 180 console.info('createAsset successfully'); 181 } else { 182 console.error(`createAsset failed, error: ${err.code}, ${err.message}`); 183 } 184 }); 185} 186``` 187 188### createAsset 189 190createAsset(displayName: string, options: PhotoCreateOptions): Promise<PhotoAsset> 191 192Creates an image or video asset with the specified file name and options. This API uses a promise to return the result. 193 194The file name must comply with the following specifications: 195- The file name consists of a valid file name and an image or video file name extension. 196- The file name cannot exceed 255 characters. 197- The file name cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ] 198 199**System API**: This is a system API. 200 201**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 202 203**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 204 205**Parameters** 206 207| Name | Type | Mandatory| Description | 208| -------- | ------------------------ | ---- | ------------------------- | 209| displayName | string | Yes | File name of the image or video to create. | 210| options | [PhotoCreateOptions](#photocreateoptions) | Yes | Options for creating an image or video asset. | 211 212**Return value** 213 214| Type | Description | 215| --------------------------- | -------------- | 216| Promise<[PhotoAsset](#photoasset)> | Promise used to return the created image and video asset.| 217 218**Error codes** 219 220For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 221 222| ID| Error Message| 223| -------- | ---------------------------------------- | 224| 202 | Called by non-system application. | 225| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 226| 13900012 | Permission denied. | 227| 13900020 | Invalid argument. | 228| 14000001 | Invalid display name. | 229| 14000011 | System inner fail. | 230 231**Example** 232 233```ts 234async function example() { 235 console.info('createAssetDemo'); 236 try { 237 let testFileName:string = 'testFile' + Date.now() + '.jpg'; 238 let createOption: photoAccessHelper.PhotoCreateOptions = { 239 subtype: photoAccessHelper.PhotoSubtype.DEFAULT 240 } 241 let photoAsset: photoAccessHelper.PhotoAsset = await phAccessHelper.createAsset(testFileName, createOption); 242 console.info('createAsset file displayName' + photoAsset.displayName); 243 console.info('createAsset successfully'); 244 } catch (err) { 245 console.error(`createAsset failed, error: ${err.code}, ${err.message}`); 246 } 247} 248``` 249 250### createAlbum<sup>(deprecated)</sup> 251 252createAlbum(name: string, callback: AsyncCallback<Album>): void 253 254Creates an album. This API uses an asynchronous callback to return the result. 255 256The album name must meet the following requirements: 257- The album name cannot exceed 255 characters. 258- The album name cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ] 259- The album name is case-insensitive. 260- Duplicate album names are not allowed. 261 262> **NOTE** 263> 264> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.createAlbumRequest](#createalbumrequest11) instead. 265 266**System API**: This is a system API. 267 268**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 269 270**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 271 272**Parameters** 273 274| Name | Type | Mandatory| Description | 275| -------- | ------------------------ | ---- | ------------------------- | 276| name | string | Yes | Name of the album to create. | 277| callback | AsyncCallback<[Album](#album)> | Yes | Callback used to return the created album instance.| 278 279**Error codes** 280 281For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 282 283| ID| Error Message| 284| -------- | ---------------------------------------- | 285| 202 | Called by non-system application. | 286| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 287| 13900012 | Permission denied. | 288| 13900015 | File exists. | 289| 13900020 | Invalid argument. | 290| 14000011 | System inner fail. | 291 292**Example** 293 294```ts 295async function example() { 296 console.info('createAlbumDemo'); 297 let albumName: string = 'newAlbumName' + new Date().getTime(); 298 phAccessHelper.createAlbum(albumName, (err, album) => { 299 if (err) { 300 console.error(`createAlbumCallback failed with err: ${err.code}, ${err.message}`); 301 return; 302 } 303 console.info('createAlbumCallback successfully, album: ' + album.albumName + ' album uri: ' + album.albumUri); 304 }); 305} 306``` 307 308### createAlbum<sup>(deprecated)</sup> 309 310createAlbum(name: string): Promise<Album> 311 312Creates an album. This API uses a promise to return the result. 313 314The album name must meet the following requirements: 315- The album name cannot exceed 255 characters. 316- The album name cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ] 317- The album name is case-insensitive. 318- Duplicate album names are not allowed. 319 320> **NOTE** 321> 322> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.createAlbumRequest](#createalbumrequest11) instead. 323 324**System API**: This is a system API. 325 326**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 327 328**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 329 330**Parameters** 331 332| Name | Type | Mandatory| Description | 333| -------- | ------------------------ | ---- | ------------------------- | 334| name | string | Yes | Name of the album to create. | 335 336**Return value** 337 338| Type | Description | 339| --------------------------- | -------------- | 340| Promise<[Album](#album)> | Promise used to return the created album instance.| 341 342**Error codes** 343 344For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 345 346| ID| Error Message| 347| -------- | ---------------------------------------- | 348| 202 | Called by non-system application. | 349| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 350| 13900012 | Permission denied. | 351| 13900015 | File exists. | 352| 13900020 | Invalid argument. | 353| 14000011 | System inner fail. | 354 355**Example** 356 357```ts 358import { BusinessError } from '@kit.BasicServicesKit'; 359 360async function example() { 361 console.info('createAlbumDemo'); 362 let albumName: string = 'newAlbumName' + new Date().getTime(); 363 phAccessHelper.createAlbum(albumName).then((album) => { 364 console.info('createAlbumPromise successfully, album: ' + album.albumName + ' album uri: ' + album.albumUri); 365 }).catch((err: BusinessError) => { 366 console.error(`createAlbumPromise failed with err: ${err.code}, ${err.message}`); 367 }); 368} 369``` 370 371### deleteAlbums<sup>(deprecated)</sup> 372 373deleteAlbums(albums: Array<Album>, callback: AsyncCallback<void>): void 374 375Deletes albums. This API uses an asynchronous callback to return the result. 376 377Ensure that the albums to be deleted exist. Only user albums can be deleted. 378 379> **NOTE** 380> 381> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.deleteAlbums](#deletealbums11) instead. 382 383**System API**: This is a system API. 384 385**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 386 387**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 388 389**Parameters** 390 391| Name | Type | Mandatory| Description | 392| -------- | ------------------------ | ---- | ------------------------- | 393| albums | Array<[Album](#album)> | Yes | Albums to delete. | 394| callback | AsyncCallback<void> | Yes | Callback that returns no value.| 395 396**Error codes** 397 398For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 399 400| ID| Error Message| 401| -------- | ---------------------------------------- | 402| 202 | Called by non-system application. | 403| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 404| 13900012 | Permission denied. | 405| 13900020 | Invalid argument. | 406| 14000011 | System inner fail. | 407 408**Example** 409 410```ts 411import { dataSharePredicates } from '@kit.ArkData'; 412 413async function example() { 414 // Delete the album named newAlbumName. 415 console.info('deleteAlbumsDemo'); 416 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 417 predicates.equalTo('album_name', 'newAlbumName'); 418 let fetchOptions: photoAccessHelper.FetchOptions = { 419 fetchColumns: [], 420 predicates: predicates 421 }; 422 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions); 423 let album: photoAccessHelper.Album = await fetchResult.getFirstObject(); 424 phAccessHelper.deleteAlbums([album], (err) => { 425 if (err) { 426 console.error(`deletePhotoAlbumsCallback failed with err: ${err.code}, ${err.message}`); 427 return; 428 } 429 console.info('deletePhotoAlbumsCallback successfully'); 430 }); 431 fetchResult.close(); 432} 433``` 434 435### deleteAlbums<sup>(deprecated)</sup> 436 437deleteAlbums(albums: Array<Album>): Promise<void> 438 439Deletes albums. This API uses a promise to return the result. 440 441Ensure that the albums to be deleted exist. Only user albums can be deleted. 442 443> **NOTE** 444> 445> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.deleteAlbums](#deletealbums11) instead. 446 447**System API**: This is a system API. 448 449**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 450 451**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 452 453**Parameters** 454 455| Name | Type | Mandatory| Description | 456| -------- | ------------------------ | ---- | ------------------------- | 457| albums | Array<[Album](#album)> | Yes | Albums to delete. | 458 459**Return value** 460 461| Type | Description | 462| --------------------------- | -------------- | 463| Promise<void> | Promise that returns no value.| 464 465**Error codes** 466 467For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 468 469| ID| Error Message| 470| -------- | ---------------------------------------- | 471| 202 | Called by non-system application. | 472| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 473| 13900012 | Permission denied. | 474| 13900020 | Invalid argument. | 475| 14000011 | System inner fail. | 476 477**Example** 478 479```ts 480import { dataSharePredicates } from '@kit.ArkData'; 481import { BusinessError } from '@kit.BasicServicesKit'; 482 483async function example() { 484 // Delete the album named newAlbumName. 485 console.info('deleteAlbumsDemo'); 486 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 487 predicates.equalTo('album_name', 'newAlbumName'); 488 let fetchOptions: photoAccessHelper.FetchOptions = { 489 fetchColumns: [], 490 predicates: predicates 491 }; 492 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions); 493 let album: photoAccessHelper.Album = await fetchResult.getFirstObject(); 494 phAccessHelper.deleteAlbums([album]).then(() => { 495 console.info('deletePhotoAlbumsPromise successfully'); 496 }).catch((err: BusinessError) => { 497 console.error(`deletePhotoAlbumsPromise failed with err: ${err.code}, ${err.message}`); 498 }); 499 fetchResult.close(); 500} 501``` 502 503### getHiddenAlbums<sup>11+</sup> 504 505getHiddenAlbums(mode: HiddenPhotosDisplayMode, options: FetchOptions, callback: AsyncCallback<FetchResult<Album>>): void 506 507Obtains hidden albums based on the specified display mode and retrieval options. This API uses an asynchronous callback to return the result. 508 509**System API**: This is a system API. 510 511**Required permissions**: ohos.permission.READ_IMAGEVIDEO and ohos.permission.MANAGE_PRIVATE_PHOTOS 512 513**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 514 515**Parameters** 516 517| Name | Type | Mandatory| Description | 518| -------- | ------------------------ | ---- | ------------------------- | 519| mode | [HiddenPhotosDisplayMode](#hiddenphotosdisplaymode11) | Yes | Display mode of hidden files. | 520| options | [FetchOptions](js-apis-photoAccessHelper.md#fetchoptions) | Yes | Options for retrieving the hidden files. | 521| callback | AsyncCallback<[FetchResult](js-apis-photoAccessHelper.md#fetchresult)<[Album](#album)>> | Yes | Callback used to return the result.| 522 523**Error codes** 524 525For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 526 527| ID| Error Message| 528| -------- | ---------------------------------------- | 529| 201 | Permission verification failed, usually the result returned by VerifyAccessToken. | 530| 202 | Permission verification failed, application which is not a system application uses system API. | 531| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 532| 14000011 | System inner fail. | 533 534**Example** 535 536```ts 537import { dataSharePredicates } from '@kit.ArkData'; 538 539// Obtain the album newAlbumName that contains hidden files. 540async function getHiddenAlbumsView() { 541 console.info('getHiddenAlbumsViewDemo'); 542 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 543 predicates.equalTo('album_name', 'newAlbumName'); 544 let fetchOptions: photoAccessHelper.FetchOptions = { 545 fetchColumns: [], 546 predicates: predicates 547 }; 548 phAccessHelper.getHiddenAlbums(photoAccessHelper.HiddenPhotosDisplayMode.ALBUMS_MODE, fetchOptions, 549 async (err, fetchResult) => { 550 if (fetchResult === undefined) { 551 console.error('getHiddenAlbumsViewCallback fetchResult is undefined'); 552 return; 553 } 554 let album = await fetchResult.getFirstObject(); 555 console.info('getHiddenAlbumsViewCallback successfully, album name: ' + album.albumName); 556 fetchResult.close(); 557 }); 558} 559``` 560 561### getHiddenAlbums<sup>11+</sup> 562 563getHiddenAlbums(mode: HiddenPhotosDisplayMode, callback: AsyncCallback<FetchResult<Album>>): void 564 565Obtains hidden albums based on the specified display mode. This API uses an asynchronous callback to return the result. 566 567**System API**: This is a system API. 568 569**Required permissions**: ohos.permission.READ_IMAGEVIDEO and ohos.permission.MANAGE_PRIVATE_PHOTOS 570 571**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 572 573**Parameters** 574 575| Name | Type | Mandatory| Description | 576| -------- | ------------------------ | ---- | ------------------------- | 577| mode | [HiddenPhotosDisplayMode](#hiddenphotosdisplaymode11) | Yes | Display mode of hidden files. | 578| callback | AsyncCallback<[FetchResult](js-apis-photoAccessHelper.md#fetchresult)<[Album](#album)>> | Yes | Callback used to return the result.| 579 580**Error codes** 581 582For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 583 584| ID| Error Message| 585| -------- | ---------------------------------------- | 586| 201 | Permission verification failed, usually the result returned by VerifyAccessToken. | 587| 202 | Permission verification failed, application which is not a system application uses system API. | 588| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 589| 14000011 | System inner fail. | 590 591**Example** 592 593```ts 594import { dataSharePredicates } from '@kit.ArkData'; 595 596// Obtain the preset hidden album. 597async function getSysHiddenAlbum() { 598 console.info('getSysHiddenAlbumDemo'); 599 phAccessHelper.getHiddenAlbums(photoAccessHelper.HiddenPhotosDisplayMode.ASSETS_MODE, async (err, fetchResult) => { 600 if (fetchResult === undefined) { 601 console.error('getSysHiddenAlbumCallback fetchResult is undefined'); 602 return; 603 } 604 let hiddenAlbum: photoAccessHelper.Album = await fetchResult.getFirstObject(); 605 console.info('getSysHiddenAlbumCallback successfully, albumUri: ' + hiddenAlbum.albumUri); 606 fetchResult.close(); 607 }); 608} 609 610// Obtain the hidden albums displayed by album, that is, the albums with hidden files. Such albums do not include the preset hidden album and the albums in the trash. 611async function getHiddenAlbumsView() { 612 console.info('getHiddenAlbumsViewDemo'); 613 phAccessHelper.getHiddenAlbums(photoAccessHelper.HiddenPhotosDisplayMode.ALBUMS_MODE, async (err, fetchResult) => { 614 if (fetchResult === undefined) { 615 console.error('getHiddenAlbumsViewCallback fetchResult is undefined'); 616 return; 617 } 618 let albums: Array<photoAccessHelper.Album> = await fetchResult.getAllObjects(); 619 console.info('getHiddenAlbumsViewCallback successfully, albums size: ' + albums.length); 620 621 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 622 let fetchOption: photoAccessHelper.FetchOptions = { 623 fetchColumns: [], 624 predicates: predicates 625 }; 626 for (let i = 0; i < albums.length; i++) { 627 // Obtain hidden files in the album. 628 albums[i].getAssets(fetchOption, (err, assetFetchResult) => { 629 console.info('album get hidden assets successfully, getCount: ' + assetFetchResult.getCount()); 630 }); 631 } 632 fetchResult.close(); 633 }); 634} 635``` 636 637### getHiddenAlbums<sup>11+</sup> 638 639getHiddenAlbums(mode: HiddenPhotosDisplayMode, options?: FetchOptions): Promise<FetchResult<Album>> 640 641Obtains hidden albums based on the specified display mode and retrieval options. This API uses a promise to return the result. 642 643**System API**: This is a system API. 644 645**Required permissions**: ohos.permission.READ_IMAGEVIDEO and ohos.permission.MANAGE_PRIVATE_PHOTOS 646 647**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 648 649**Parameters** 650 651| Name | Type | Mandatory| Description | 652| -------- | ------------------------ | ---- | ------------------------- | 653| mode | [HiddenPhotosDisplayMode](#hiddenphotosdisplaymode11) | Yes | Display mode of hidden files. | 654| options | [FetchOptions](js-apis-photoAccessHelper.md#fetchoptions) | No | Options for retrieving the files. If this parameter is not specified, the files are retrieved based on the display mode of hidden files. | 655 656**Return value** 657 658| Type | Description | 659| --------------------------- | -------------- | 660| Promise<[FetchResult](js-apis-photoAccessHelper.md#fetchresult)<[Album](#album)>> | Promise used to return the result. 661 662**Error codes** 663 664For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 665 666| ID| Error Message| 667| -------- | ---------------------------------------- | 668| 201 | Permission verification failed, usually the result returned by VerifyAccessToken. | 669| 202 | Permission verification failed, application which is not a system application uses system API. | 670| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 671| 14000011 | System inner fail. | 672 673**Example** 674 675```ts 676import { dataSharePredicates } from '@kit.ArkData'; 677import { BusinessError } from '@kit.BasicServicesKit'; 678 679// Obtain the preset hidden album. 680async function getSysHiddenAlbum() { 681 console.info('getSysHiddenAlbumDemo'); 682 phAccessHelper.getHiddenAlbums(photoAccessHelper.HiddenPhotosDisplayMode.ASSETS_MODE) 683 .then( async (fetchResult) => { 684 if (fetchResult === undefined) { 685 console.error('getSysHiddenAlbumPromise fetchResult is undefined'); 686 return; 687 } 688 let hiddenAlbum: photoAccessHelper.Album = await fetchResult.getFirstObject(); 689 console.info('getAlbumsPromise successfully, albumUri: ' + hiddenAlbum.albumUri); 690 fetchResult.close(); 691 }).catch((err: BusinessError) => { 692 console.error(`getSysHiddenAlbumPromise failed with err: ${err.code}, ${err.message}`); 693 }); 694} 695 696// Obtain the hidden albums displayed by album, that is, the albums with hidden files. Such albums do not include the preset hidden album and the albums in the trash. 697async function getHiddenAlbumsView() { 698 console.info('getHiddenAlbumsViewDemo'); 699 phAccessHelper.getHiddenAlbums(photoAccessHelper.HiddenPhotosDisplayMode.ALBUMS_MODE).then( async (fetchResult) => { 700 if (fetchResult === undefined) { 701 console.error('getHiddenAlbumsViewPromise fetchResult is undefined'); 702 return; 703 } 704 let albums: Array<photoAccessHelper.Album> = await fetchResult.getAllObjects(); 705 console.info('getHiddenAlbumsViewPromise successfully, albums size: ' + albums.length); 706 707 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 708 let fetchOption: photoAccessHelper.FetchOptions = { 709 fetchColumns: [], 710 predicates: predicates 711 }; 712 for (let i = 0; i < albums.length; i++) { 713 // Obtain hidden files in the album. 714 albums[i].getAssets(fetchOption).then((assetFetchResult) => { 715 console.info('album get hidden assets successfully, getCount: ' + assetFetchResult.getCount()); 716 }).catch((err: BusinessError) => { 717 console.error(`album get hidden assets failed with error: ${err.code}, ${err.message}`); 718 }); 719 } 720 fetchResult.close(); 721 }).catch((err: BusinessError) => { 722 console.error(`getHiddenAlbumsViewPromise failed with err: ${err.code}, ${err.message}`); 723 }); 724} 725``` 726 727### deleteAssets<sup>(deprecated)</sup> 728 729deleteAssets(uriList: Array<string>, callback: AsyncCallback<void>): void 730 731Deletes media assets. This API uses an asynchronous callback to return the result. The deleted assets are moved to the trash. 732 733> **NOTE** 734> 735> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.deleteAssets](js-apis-photoAccessHelper.md#deleteassets11) instead. 736 737**System API**: This is a system API. 738 739**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 740 741**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 742 743**Parameters** 744 745| Name | Type | Mandatory| Description | 746| -------- | ------------------------- | ---- | ---------- | 747| uriList | Array<string> | Yes | URIs of the media files to delete.| 748| callback | AsyncCallback<void> | Yes | Callback that returns no value.| 749 750**Error codes** 751 752For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 753 754| ID| Error Message| 755| -------- | ---------------------------------------- | 756| 202 | Called by non-system application. | 757| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 758| 13900012 | Permission denied. | 759| 13900020 | Invalid argument. | 760| 14000002 | Invalid uri. | 761| 14000011 | System inner fail. | 762 763**Example** 764 765```ts 766import { dataSharePredicates } from '@kit.ArkData'; 767 768async function example() { 769 console.info('deleteAssetDemo'); 770 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 771 let fetchOptions: photoAccessHelper.FetchOptions = { 772 fetchColumns: [], 773 predicates: predicates 774 }; 775 try { 776 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions); 777 let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 778 if (asset === undefined) { 779 console.error('asset not exist'); 780 return; 781 } 782 phAccessHelper.deleteAssets([asset.uri], (err) => { 783 if (err === undefined) { 784 console.info('deleteAssets successfully'); 785 } else { 786 console.error(`deleteAssets failed with error: ${err.code}, ${err.message}`); 787 } 788 }); 789 } catch (err) { 790 console.error(`fetch failed, error: ${err.code}, ${err.message}`); 791 } 792} 793``` 794 795### deleteAssets<sup>(deprecated)</sup> 796 797deleteAssets(uriList: Array<string>): Promise<void> 798 799Deletes media assets. This API uses a promise to return the result. The deleted assets are moved to the trash. 800 801> **NOTE** 802> 803> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.deleteAssets](js-apis-photoAccessHelper.md#deleteassets11) instead. 804 805**System API**: This is a system API. 806 807**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 808 809**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 810 811**Parameters** 812 813| Name | Type | Mandatory| Description | 814| -------- | ------------------------- | ---- | ---------- | 815| uriList | Array<string> | Yes | URIs of the media files to delete.| 816 817**Return value** 818 819| Type | Description | 820| --------------------------------------- | ----------------- | 821| Promise<void>| Promise that returns no value.| 822 823**Error codes** 824 825For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 826 827| ID| Error Message| 828| -------- | ---------------------------------------- | 829| 202 | Called by non-system application. | 830| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 831| 13900012 | Permission denied. | 832| 13900020 | Invalid argument. | 833| 14000002 | Invalid uri. | 834| 14000011 | System inner fail. | 835 836**Example** 837 838```ts 839import { dataSharePredicates } from '@kit.ArkData'; 840 841async function example() { 842 console.info('deleteDemo'); 843 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 844 let fetchOptions: photoAccessHelper.FetchOptions = { 845 fetchColumns: [], 846 predicates: predicates 847 }; 848 try { 849 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions); 850 let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 851 if (asset === undefined) { 852 console.error('asset not exist'); 853 return; 854 } 855 await phAccessHelper.deleteAssets([asset.uri]); 856 console.info('deleteAssets successfully'); 857 } catch (err) { 858 console.error(`deleteAssets failed with error: ${err.code}, ${err.message}`); 859 } 860} 861``` 862 863### getPhotoIndex 864 865getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions, callback: AsyncCallback<number>): void 866 867Obtains the index of an image or video in an album. This API uses an asynchronous callback to return the result. 868 869**System API**: This is a system API. 870 871**Required permissions**: ohos.permission.READ_IMAGEVIDEO 872 873**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 874 875**Parameters** 876 877| Name | Type | Mandatory| Description | 878| -------- | ------------------------- | ---- | ---------- | 879| photoUri | string | Yes | URI of the media asset whose index is to be obtained.| 880| albumUri | string | Yes | Album URI, which can be an empty string. If it is an empty string, all the media assets in the Gallery are obtained by default. | 881| options | [FetchOptions](js-apis-photoAccessHelper.md#fetchoptions) | Yes | Fetch options. Only one search condition or sorting mode must be set in **predicates**. If no value is set or multiple search criteria or sorting modes are set, the API cannot be called successfully. | 882| callback | AsyncCallback<number>| Yes | Callback used to return the index obtained.| 883 884**Error codes** 885 886For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 887 888| ID| Error Message| 889| -------- | ---------------------------------------- | 890| 202 | Called by non-system application. | 891| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 892| 13900012 | Permission denied. | 893| 13900020 | Invalid argument. | 894| 14000011 | System inner fail. | 895 896**Example** 897 898```ts 899import { dataSharePredicates } from '@kit.ArkData'; 900 901async function example() { 902 try { 903 console.info('getPhotoIndexDemo'); 904 let predicatesForGetAsset: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 905 let fetchOp: photoAccessHelper.FetchOptions = { 906 fetchColumns: [], 907 predicates: predicatesForGetAsset 908 }; 909 // Obtain the uri of the album 910 let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.FAVORITE, fetchOp); 911 let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject(); 912 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 913 predicates.orderByAsc(photoAccessHelper.PhotoKeys.DATE_MODIFIED); 914 let fetchOptions: photoAccessHelper.FetchOptions = { 915 fetchColumns: [photoAccessHelper.PhotoKeys.DATE_MODIFIED], 916 predicates: predicates 917 }; 918 let photoFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions); 919 let expectIndex = 1; 920 // Obtain the uri of the second file 921 let photoAsset: photoAccessHelper.PhotoAsset = await photoFetchResult.getObjectByPosition(expectIndex); 922 923 phAccessHelper.getPhotoIndex(photoAsset.uri, album.albumUri, fetchOptions, (err, index) => { 924 if (err === undefined) { 925 console.info(`getPhotoIndex successfully and index is : ${index}`); 926 } else { 927 console.error(`getPhotoIndex failed; error: ${err.code}, ${err.message}`); 928 } 929 }); 930 } catch (error) { 931 console.error(`getPhotoIndex failed; error: ${error.code}, ${error.message}`); 932 } 933} 934``` 935 936### getPhotoIndex 937 938getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions): Promise<number> 939 940Obtains the index of an image or video in an album. This API uses a promise to return the result. 941 942**System API**: This is a system API. 943 944**Required permissions**: ohos.permission.READ_IMAGEVIDEO 945 946**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 947 948**Parameters** 949 950| Name | Type | Mandatory| Description | 951| -------- | ------------------------- | ---- | ---------- | 952| photoUri | string | Yes | URI of the media asset whose index is to be obtained.| 953| albumUri | string | Yes | Album URI, which can be an empty string. If it is an empty string, all the media assets in the Gallery are obtained by default. | 954| options | [FetchOptions](js-apis-photoAccessHelper.md#fetchoptions) | Yes | Fetch options. Only one search condition or sorting mode must be set in **predicates**. If no value is set or multiple search criteria or sorting modes are set, the API cannot be called successfully. | 955 956**Return value** 957 958| Type | Description | 959| --------------------------------------- | ----------------- | 960| Promise<number>| Promise used to return the index obtained.| 961 962**Error codes** 963 964For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 965 966| ID| Error Message| 967| -------- | ---------------------------------------- | 968| 202 | Called by non-system application. | 969| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 970| 13900012 | Permission denied. | 971| 13900020 | Invalid argument. | 972| 14000011 | System inner fail. | 973 974**Example** 975 976```ts 977import { dataSharePredicates } from '@kit.ArkData'; 978import { BusinessError } from '@kit.BasicServicesKit'; 979 980async function example() { 981 try { 982 console.info('getPhotoIndexDemo'); 983 let predicatesForGetAsset: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 984 let fetchOp: photoAccessHelper.FetchOptions = { 985 fetchColumns: [], 986 predicates: predicatesForGetAsset 987 }; 988 // Obtain the uri of the album 989 let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.FAVORITE, fetchOp); 990 let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject(); 991 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 992 predicates.orderByAsc(photoAccessHelper.PhotoKeys.DATE_MODIFIED); 993 let fetchOptions: photoAccessHelper.FetchOptions = { 994 fetchColumns: [photoAccessHelper.PhotoKeys.DATE_MODIFIED], 995 predicates: predicates 996 }; 997 let photoFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions); 998 let expectIndex = 1; 999 // Obtain the uri of the second file 1000 let photoAsset: photoAccessHelper.PhotoAsset = await photoFetchResult.getObjectByPosition(expectIndex); 1001 phAccessHelper.getPhotoIndex(photoAsset.uri, album.albumUri, fetchOptions).then((index) => { 1002 console.info(`getPhotoIndex successfully and index is : ${index}`); 1003 }).catch((err: BusinessError) => { 1004 console.error(`getPhotoIndex failed; error: ${err.code}, ${err.message}`); 1005 }); 1006 } catch (error) { 1007 console.error(`getPhotoIndex failed; error: ${error.code}, ${error.message}`); 1008 } 1009} 1010``` 1011 1012### saveFormInfo<sup>11+</sup> 1013 1014saveFormInfo(info:FormInfo, callback: AsyncCallback<void>):void 1015 1016Saves a Gallery widget. This API uses an asynchronous callback to return the result. 1017 1018**System API**: This is a system API. 1019 1020**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 1021 1022**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 1023 1024**Parameters** 1025 1026| Name | Type | Mandatory| Description | 1027| -------- | ------------------------ | ---- | ------------------------- | 1028| info | [FormInfo](#forminfo11) | Yes | Information about the Gallery widget to save, which includes the ID of the widget and the URI of the image bound to the widget. | 1029| callback | AsyncCallback<void> | Yes | Callback that returns no value.| 1030 1031**Error codes** 1032 1033For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 1034 1035| ID| Error Message| 1036| -------- | ---------------------------------------- | 1037| 201 | Permission verification failed, usually the result returned by VerifyAccessToken. | 1038| 202 | Permission verification failed, application which is not a system application uses system API. | 1039| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1040| 14000011 | System inner fail. | 1041 1042 1043**Example** 1044 1045```ts 1046import { dataSharePredicates } from '@kit.ArkData'; 1047import { BusinessError } from '@kit.BasicServicesKit'; 1048 1049async function example() { 1050 console.info('saveFormInfoDemo'); 1051 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 1052 let fetchOptions: photoAccessHelper.FetchOptions = { 1053 fetchColumns: [], 1054 predicates: predicates 1055 }; 1056 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions); 1057 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 1058 1059 let info: photoAccessHelper.FormInfo = { 1060 // formId is a string consisting of only digits. uri indicates the URI of the image in Gallery. If there is no image in Gallery, uri must be an empty string. 1061 formId : "20230116123", 1062 uri: photoAsset.uri, 1063 } 1064 1065 phAccessHelper.saveFormInfo(info, async (err: BusinessError) => { 1066 if (err == undefined) { 1067 console.info('saveFormInfo success'); 1068 } else { 1069 console.error(`saveFormInfo fail with error: ${err.code}, ${err.message}`); 1070 } 1071 }); 1072} 1073``` 1074 1075### saveFormInfo<sup>11+</sup> 1076 1077saveFormInfo(info:FormInfo):Promise<void> 1078 1079Saves a Gallery widget. This API uses a promise to return the result. 1080 1081**System API**: This is a system API. 1082 1083**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 1084 1085**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 1086 1087**Parameters** 1088 1089| Name | Type | Mandatory| Description | 1090| -------- | ------------------------ | ---- | ------------------------- | 1091| info | [FormInfo](#forminfo11) | Yes | Information about the Gallery widget to save, which includes the ID of the widget and the URI of the image bound to the widget. | 1092 1093**Return value** 1094 1095| Type | Description | 1096| --------------------------------------- | ----------------- | 1097| Promise<void>| Promise that returns no value.| 1098 1099**Error codes** 1100 1101For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 1102 1103| ID| Error Message| 1104| -------- | ---------------------------------------- | 1105| 201 | Permission verification failed, usually the result returned by VerifyAccessToken. | 1106| 202 | Permission verification failed, application which is not a system application uses system API. | 1107| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1108| 14000011 | System inner fail. | 1109 1110**Example** 1111 1112```ts 1113import { dataSharePredicates } from '@kit.ArkData'; 1114import { BusinessError } from '@kit.BasicServicesKit'; 1115 1116async function example() { 1117 console.info('saveFormInfoDemo'); 1118 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 1119 let fetchOptions: photoAccessHelper.FetchOptions = { 1120 fetchColumns: [], 1121 predicates: predicates 1122 }; 1123 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions); 1124 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 1125 1126 let info: photoAccessHelper.FormInfo = { 1127 // formId is a string consisting of only digits. uri indicates the URI of the image in Gallery. If there is no image in Gallery, uri must be an empty string. 1128 formId: "20230116123", 1129 uri: photoAsset.uri, 1130 } 1131 1132 phAccessHelper.saveFormInfo(info).then(() => { 1133 console.info('saveFormInfo successfully'); 1134 }).catch((err: BusinessError) => { 1135 console.error(`saveFormInfo failed with error: ${err.code}, ${err.message}`); 1136 }); 1137} 1138``` 1139 1140### removeFormInfo<sup>11+</sup> 1141 1142removeFormInfo(info:FormInfo, callback: AsyncCallback<void>):void 1143 1144Removes a Gallery widget. This API uses an asynchronous callback to return the result. 1145 1146**System API**: This is a system API. 1147 1148**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 1149 1150**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 1151 1152**Parameters** 1153 1154| Name | Type | Mandatory| Description | 1155| -------- | ------------------------ | ---- | ------------------------- | 1156| info | [FormInfo](#forminfo11) | Yes | Information about the Gallery widget to save, which includes the ID of the widget and the URI of the image bound to the widget. | 1157| callback | AsyncCallback<void> | Yes | Callback that returns no value.| 1158 1159**Error codes** 1160 1161For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 1162 1163| ID| Error Message| 1164| -------- | ---------------------------------------- | 1165| 201 | Permission verification failed, usually the result returned by VerifyAccessToken. | 1166| 202 | Permission verification failed, application which is not a system application uses system API. | 1167| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1168| 14000011 | System inner fail. | 1169 1170**Example** 1171 1172```ts 1173import { BusinessError } from '@kit.BasicServicesKit'; 1174 1175async function example() { 1176 console.info('removeFormInfoDemo'); 1177 let info: photoAccessHelper.FormInfo = { 1178 // formId is a string consisting of only digits. When removing a widget, leave uri empty. 1179 formId: "20230116123", 1180 uri: "", 1181 } 1182 1183 phAccessHelper.removeFormInfo(info, async (err: BusinessError) => { 1184 if (err == undefined) { 1185 console.info('removeFormInfo success'); 1186 } else { 1187 console.error(`removeFormInfo fail with error: ${err.code}, ${err.message}`); 1188 } 1189 }); 1190} 1191``` 1192 1193### removeFormInfo<sup>11+</sup> 1194 1195removeFormInfo(info:FormInfo):Promise<void> 1196 1197Removes a Gallery widget. This API uses a promise to return the result. 1198 1199**System API**: This is a system API. 1200 1201**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 1202 1203**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 1204 1205**Parameters** 1206 1207| Name | Type | Mandatory| Description | 1208| -------- | ------------------------ | ---- | ------------------------- | 1209| info | [FormInfo](#forminfo11) | Yes | Information about the Gallery widget to save, which includes the ID of the widget and the URI of the image bound to the widget. | 1210 1211**Return value** 1212 1213| Type | Description | 1214| --------------------------------------- | ----------------- | 1215| Promise<void>| Promise that returns no value.| 1216 1217**Error codes** 1218 1219For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 1220 1221| ID| Error Message| 1222| -------- | ---------------------------------------- | 1223| 201 | Permission verification failed, usually the result returned by VerifyAccessToken. | 1224| 202 | Permission verification failed, application which is not a system application uses system API. | 1225| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1226| 14000011 | System inner fail. | 1227 1228**Example** 1229 1230```ts 1231import { BusinessError } from '@kit.BasicServicesKit'; 1232 1233async function example() { 1234 console.info('removeFormInfoDemo'); 1235 let info: photoAccessHelper.FormInfo = { 1236 // formId is a string consisting of only digits. When removing a widget, leave uri empty. 1237 formId: "20230116123", 1238 uri: "", 1239 } 1240 1241 phAccessHelper.removeFormInfo(info).then(() => { 1242 console.info('removeFormInfo successfully'); 1243 }).catch((err: BusinessError) => { 1244 console.error(`removeFormInfo failed with error: ${err.code}, ${err.message}`); 1245 }); 1246} 1247``` 1248 1249### createAssetsForApp<sup>12+</sup> 1250 1251createAssetsForApp(bundleName: string, appName: string, appId: string, photoCreationConfigs: Array<PhotoCreationConfig>): Promise<Array<string>> 1252 1253Creates media assets for an application. The returned URIs has been granted with the permission for writing the media assets (images or videos). 1254 1255**System API**: This is a system API. 1256 1257**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 1258 1259**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 1260 1261**Parameters** 1262 1263| Name | Type | Mandatory| Description | 1264| -------- |----------------------------------------------------------------------| ---- | ------------------------- | 1265| bundleName | string | Yes| Bundle name of the target application.| 1266| appName | string | Yes| Name of the target application.| 1267| appId | string | Yes| ID of the target application.| 1268| photoCreationConfigs | Array<[PhotoCreationConfig](./js-apis-photoAccessHelper.md#photocreationconfig12)> | Yes| Configuration for creating (saving) the media assets in the media library.| 1269 1270**Return value** 1271 1272| Type | Description | 1273| --------------------------------------- | ----------------- | 1274| Promise<Array<string>> | Promise used to return the URIs of the media asset files in the media library. The target application (identified by **appid**) can write the media assets based on the URIs without requesting the write permission.| 1275 1276**Error codes** 1277 1278For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 1279 1280| ID| Error Message| 1281| -------- | ---------------------------------------- | 1282| 201 | Permission denied. | 1283| 202 | Called by non-system application. | 1284| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types; 3. Parameter verification failed. | 1285| 14000011 | Internal system error. | 1286 1287**Example** 1288 1289```ts 1290async function example() { 1291 console.info('createAssetsForAppDemo.'); 1292 1293 try { 1294 let bundleName: string = 'testBundleName'; 1295 let appName: string = 'testAppName'; 1296 let appId: string = 'testAppId'; 1297 let photoCreationConfigs: Array<photoAccessHelper.PhotoCreationConfig> = [ 1298 { 1299 title: 'test', 1300 fileNameExtension: 'jpg', 1301 photoType: photoAccessHelper.PhotoType.IMAGE, 1302 subtype: photoAccessHelper.PhotoSubtype.DEFAULT, 1303 } 1304 ]; 1305 let desFileUris: Array<string> = await phAccessHelper.createAssetsForApp(bundleName, appName, appId, photoCreationConfigs); 1306 console.info('createAssetsForApp success, data is ' + desFileUris); 1307 } catch (err) { 1308 console.error(`createAssetsForApp failed with error: ${err.code}, ${err.message}`); 1309 } 1310} 1311``` 1312 1313### grantPhotoUriPermission<sup>12+</sup> 1314 1315grantPhotoUriPermission(appid: string, uri: string, photoPermissionType: PhotoPermissionType, hideSensitiveType: HideSensitiveType): Promise<number> 1316 1317Grants an application the permission to access a URI. This API uses a promise to return the result. 1318 1319**System API**: This is a system API. 1320 1321**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 1322 1323**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 1324 1325**Parameters** 1326 1327| Name | Type | Mandatory| Description | 1328| -------- |----------------------------------------------------------------------| ---- | ------------------------- | 1329| appid | string | Yes| ID of the target application.| 1330| uri | string | Yes| URI of the media asset.| 1331| photoPermissionType | [PhotoPermissionType](#photopermissiontype12) | Yes| Type of the permission to be granted. For details, see the enum.| 1332| hideSensitiveType | [HideSensitiveType](#hidesensitivetype12) | Yes| Type of the information to hide. This parameter is reserved. Currently, any enumerated value of **HideSensitiveType** can be passed in.| 1333 1334**Return value** 1335 1336| Type | Description | 1337| --------------------------------------- | ----------------- | 1338| Promise<number> | Promise used to return the result. The value **0** means the permission is granted to the application. The value **1** means the application already has the permission. The value **-1** means the permission fails to be granted.| 1339 1340**Error codes** 1341 1342For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 1343 1344| ID| Error Message| 1345| -------- | ---------------------------------------- | 1346| 201 | Permission denied. | 1347| 202 | Called by non-system application. | 1348| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types; 3. Parameter verification failed. | 1349| 14000011 | Internal system error. | 1350 1351**Example** 1352 1353```ts 1354async function example() { 1355 console.info('grantPhotoUriPermissionDemo'); 1356 1357 try { 1358 let result = await phAccessHelper.grantPhotoUriPermission('com.example.myapplication01', 1359 'file://media/Photo/1/IMG_datetime_0001/displayName.jpg', 1360 photoAccessHelper.PhotoPermissionType.TEMPORARY_READ_IMAGEVIDEO, 1361 photoAccessHelper.HideSensitiveType.HIDE_LOCATION_AND_SHOTING_PARM); 1362 1363 console.info('grantPhotoUriPermission success, result=' + result); 1364 } catch (err) { 1365 console.error('grantPhotoUriPermission failed, error=' + err); 1366 } 1367} 1368``` 1369 1370### grantPhotoUrisPermission<sup>12+</sup> 1371 1372grantPhotoUrisPermission(appid: string, uriList: Array<string>, photoPermissionType: PhotoPermissionType, hideSensitiveType: HideSensitiveType): Promise<number> 1373 1374Grants an application the permission to access multiple URIs. This API uses a promise to return the result. 1375 1376**System API**: This is a system API. 1377 1378**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 1379 1380**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 1381 1382**Parameters** 1383 1384| Name | Type | Mandatory| Description | 1385| -------- |----------------------------------------------------------------------| ---- | ------------------------- | 1386| appid | string | Yes| ID of the target application.| 1387| uriList | Array<string> | Yes| A list of URIs, which cannot exceed 1000.| 1388| photoPermissionType | [PhotoPermissionType](#photopermissiontype12) | Yes| Type of the permission to be granted. For details, see the enum.| 1389| hideSensitiveType | [HideSensitiveType](#hidesensitivetype12) | Yes| Type of the information to hide. This parameter is reserved. Currently, any enumerated value of **HideSensitiveType** can be passed in.| 1390 1391**Return value** 1392 1393| Type | Description | 1394| --------------------------------------- | ----------------- | 1395| Promise<number> | Promise used to return the result. The value **0** means the operation is successful; the value **-1** means the opposite.| 1396 1397**Error codes** 1398 1399For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 1400 1401| ID| Error Message| 1402| -------- | ---------------------------------------- | 1403| 201 | Permission denied. | 1404| 202 | Called by non-system application. | 1405| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types; 3. Parameter verification failed. | 1406| 14000011 | Internal system error. | 1407 1408**Example** 1409 1410```ts 1411async function example() { 1412 console.info('grantPhotoUrisPermissionDemo'); 1413 1414 try { 1415 // URIs of the media assets. 1416 let uris: Array<string> = [ 1417 'file://media/Photo/11/IMG_datetime_0001/displayName1.jpg', 1418 'file://media/Photo/22/IMG_datetime_0002/displayName2.jpg']; 1419 let result = await phAccessHelper.grantPhotoUrisPermission('com.example.myapplication01', uris, 1420 photoAccessHelper.PhotoPermissionType.TEMPORARY_READ_IMAGEVIDEO, 1421 photoAccessHelper.HideSensitiveType.HIDE_LOCATION_AND_SHOTING_PARM); 1422 1423 console.info('grantPhotoUrisPermission success, result=' + result); 1424 } catch (err) { 1425 console.error('grantPhotoUrisPermission failed, error=' + err); 1426 } 1427} 1428``` 1429 1430### cancelPhotoUriPermission<sup>12+</sup> 1431 1432cancelPhotoUriPermission(appid: string, uri: string, photoPermissionType: PhotoPermissionType): Promise<number> 1433 1434Cancels the permission for accessing an URI from an application. This API uses a promise to return the result. 1435 1436**System API**: This is a system API. 1437 1438**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 1439 1440**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 1441 1442**Parameters** 1443 1444| Name | Type | Mandatory| Description | 1445| -------- |----------------------------------------------------------------------| ---- | ------------------------- | 1446| appid | string | Yes| ID of the target application.| 1447| uri | string | Yes| URI of the media asset.| 1448| photoPermissionType | [PhotoPermissionType](#photopermissiontype12) | Yes| Permission type.| 1449 1450**Return value** 1451 1452| Type | Description | 1453| --------------------------------------- | ----------------- | 1454| Promise<number> | Promise used to return the result. The value **0** means the operation is successful; the value **-1** means the opposite.| 1455 1456**Error codes** 1457 1458For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 1459 1460| ID| Error Message| 1461| -------- | ---------------------------------------- | 1462| 201 | Permission denied. | 1463| 202 | Called by non-system application. | 1464| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types; 3. Parameter verification failed. | 1465| 14000011 | Internal system error. | 1466 1467**Example** 1468 1469```ts 1470async function example() { 1471 console.info('cancelPhotoUriPermissionDemo'); 1472 1473 try { 1474 let result = await phAccessHelper.cancelPhotoUriPermission('com.example.myapplication01', 1475 'file://media/Photo/11/IMG_datetime_0001/displayName.jpg', 1476 photoAccessHelper.PhotoPermissionType.TEMPORARY_READ_IMAGEVIDEO); 1477 1478 console.info('cancelPhotoUriPermission success, result=' + result); 1479 } catch (err) { 1480 console.error('cancelPhotoUriPermission failed, error=' + err); 1481 } 1482} 1483``` 1484 1485### createAssetsForAppWithMode<sup>12+</sup> 1486 1487createAssetsForAppWithMode(boundleName: string, appName: string, appId: string, tokenId: number, authorizationMode: AuthorizationMode, photoCreationConfigs:Array\<PhotoCreationConfig>): Promise\<Array\<string>> 1488 1489Creates assets with a temporary permission. This API uses a promise to return the result. 1490 1491**System API**: This is a system API. 1492 1493**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 1494 1495**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 1496 1497**Parameters** 1498 1499| Name | Type | Mandatory| Description | 1500| -------- |----------------------------------------------------------------------| ---- | ------------------------- | 1501| boundleName| string | Yes| Bundle name of the target application.| 1502| appName| string | Yes| Name of the target application.| 1503| appId| string | Yes| ID of the target application.| 1504| tokenId| number| Yes| Unique identifier for the temporary authorization.| 1505| authorizationMode| [AuthorizationMode](#authorizationmode12)| Yes| Authorization mode. No confirmation dialog box is displayed when the application with the temporary permission saves media assets in the give period of time.| 1506| PhotoCreationConfig| Array\<[PhotoCreationConfig](js-apis-photoAccessHelper.md#photocreationconfig12)> | Yes| Configuration for creating (saving) the media assets in the media library.| 1507 1508**Return value** 1509 1510| Type | Description | 1511| --------------------------------------- | ----------------- | 1512| Promise\<Array\<string>> | Promise used to return the URIs of the media asset files in the media library. The target application (identified by **appid**) can write the assets based on the URIs without has been authorized to the application specified by appId to allow the application to write data.| 1513 1514**Error codes** 1515 1516For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 1517 1518| ID| Error Message| 1519| -------- | ---------------------------------------- | 1520| 201 | Permission denied. | 1521| 202 | Called by non-system application. | 1522| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types; 3. Parameter verification failed. | 1523| 14000011 | Internal system error. | 1524 1525**Example** 1526 1527```ts 1528async function example() { 1529 console.info('createAssetsForAppWithModeDemo.'); 1530 1531 try { 1532 let photoCreationConfigs: Array<photoAccessHelper.PhotoCreationConfig> = [ 1533 { 1534 title: '123456', 1535 fileNameExtension: 'jpg', 1536 photoType: photoAccessHelper.PhotoType.IMAGE, 1537 subtype: photoAccessHelper.PhotoSubtype.DEFAULT, 1538 } 1539 ]; 1540 let bundleName: string = 'testBundleName'; 1541 let appName: string = 'testAppName'; 1542 let appId: string = 'testAppId'; 1543 let tokenId: number = 537197950; 1544 let authorizationMode: photoAccessHelper.AuthorizationMode = photoAccessHelper.AuthorizationMode.SHORT_TIME_AUTHORIZATION; 1545 let result: Array<string> = await phAccessHelper.createAssetsForAppWithMode(bundleName, appName, appId, tokenId, authorizationMode, photoCreationConfigs); 1546 console.info(`result: ${JSON.stringify(result)}`); 1547 console.info('Photo createAssetsForAppWithMode success.'); 1548 } catch (err) { 1549 console.error(`createAssetsForAppWithMode failed with error: ${err.code}, ${err.message}`); 1550 } 1551} 1552``` 1553### getKeyFrameThumbnail<sup>14+</sup> 1554 1555getKeyFrameThumbnail(beginFrameTimeMs: number, type: ThumbnailType): Promise<image.PixelMap>; 1556 1557Obtains the thumbnail of the specified type for the key frame. This API uses a promise to return the result. 1558 1559**System API**: This is a system API. 1560 1561**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 1562 1563**Required permissions**: ohos.permission.READ_IMAGEVIDEO 1564 1565**Parameters** 1566 1567| Name | Type | Mandatory | Description | 1568| ---- | -------------- | ---- | ----- | 1569| beginFrameTimeMs | number | Yes | Time of the start frame, in ms. <br>The value **0** indicates the cover frame.| 1570| type | [ThumbnailType](#thumbnailtype13)| Yes | Type of the thumbnail to obtain.| 1571 1572**Return value** 1573 1574| Type | Description | 1575| ----------------------------- | --------------------- | 1576| Promise<[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)> | Promise used to return the PixelMap of the thumbnail obtained. The cover frame is returned by default if no thumbnail is obtained.| 1577 1578**Error codes** 1579 1580For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 1581 1582| ID| Error Message| 1583| -------- | ---------------------------------------- | 1584| 201 | Permission denied. | 1585| 202 | Called by non-system application. | 1586| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1587| 14000011 | Internal system error. 1588 1589**Example** 1590 1591```ts 1592import { common } from '@kit.AbilityKit'; 1593import photoAccessHelper from '@ohos.file.photoAccessHelper'; 1594import dataSharePredicates from '@ohos.data.dataSharePredicates'; 1595import image from '@ohos.multimedia.image'; 1596 1597async function example() { 1598 try{ 1599 console.info('getKeyFrameThumbnail demo'); 1600 let context = getContext(this) as common.UIAbilityContext; 1601 let phAccessHelper:photoAccessHelper.PhotoAccessHelper = photoAccessHelper.getPhotoAccessHelper(context); 1602 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 1603 predicates.equalTo(photoAccessHelper.PhotoKeys.PHOTO_TYPE, photoAccessHelper.PhotoType.VIDEO); 1604 let fetchOption: photoAccessHelper.FetchOptions = { 1605 fetchColumns: [], 1606 predicates: predicates 1607 }; 1608 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 1609 let asset: photoAccessHelper.PhotoAsset = await fetchResult.getLastObject(); 1610 let pixelMap: image.PixelMap = await asset.getKeyFrameThumbnail(0, photoAccessHelper.ThumbnailType.LCD); 1611 console.info('getKeyFrameThumbnail success'); 1612 } catch (error) { 1613 console.error('getKeyFrameThumbnail failed, error: ' + JSON.stringify(error)); 1614 } 1615} 1616``` 1617## PhotoAsset 1618 1619Provides APIs for encapsulating file asset attributes. 1620 1621### open<sup>(deprecated)</sup> 1622 1623open(mode: string, callback: AsyncCallback<number>): void 1624 1625Opens this file asset. This API uses an asynchronous callback to return the result. 1626 1627> **NOTE** 1628> 1629> This API is supported since API version 10 and deprecated since API version 11. For security purposes, the API for obtaining the media file handle is no longer provided. 1630 1631> **NOTE**<br>A file can be opened in only one mode at a time. Use **close()** to close the FD returned when it is not required. 1632 1633**System API**: This is a system API. 1634 1635**Required permissions**: ohos.permission.READ_IMAGEVIDEO or ohos.permission.WRITE_IMAGEVIDEO 1636 1637**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 1638 1639**Parameters** 1640 1641| Name | Type | Mandatory | Description | 1642| -------- | --------------------------- | ---- | ----------------------------------- | 1643| mode | string | Yes | Mode for opening the file, which can be **'r'** (read-only), **'w'** (write-only), or **'rw'** (read/write).| 1644| callback | AsyncCallback<number> | Yes | Callback used to return the file descriptor (FD) of the file opened. | 1645 1646**Error codes** 1647 1648For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 1649 1650| ID| Error Message| 1651| -------- | ---------------------------------------- | 1652| 202 | Called by non-system application. | 1653| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1654| 13900012 | Permission denied. | 1655| 13900020 | Invalid argument. | 1656| 14000011 | System inner fail. | 1657 1658**Example** 1659 1660```ts 1661async function example() { 1662 console.info('Open demo'); 1663 let testFileName: string = 'testFile' + Date.now() + '.jpg'; 1664 let photoAsset: photoAccessHelper.PhotoAsset = await phAccessHelper.createAsset(testFileName); 1665 photoAsset.open('rw', (err, fd) => { 1666 if (fd !== undefined) { 1667 console.info('File fd' + fd); 1668 photoAsset.close(fd); 1669 } else { 1670 console.error(`Open file err: ${err.code}, ${err.message}`); 1671 } 1672 }); 1673} 1674``` 1675 1676### open<sup>(deprecated)</sup> 1677 1678open(mode: string): Promise<number> 1679 1680Opens this file asset. This API uses a promise to return the result. 1681 1682> **NOTE** 1683> 1684> This API is supported since API version 10 and deprecated since API version 11. For security purposes, the API for obtaining the media file handle is no longer provided. 1685 1686> **NOTE**<br>A file can be opened in only one mode at a time. Use **close()** to close the FD returned when it is not required. 1687 1688**System API**: This is a system API. 1689 1690**Required permissions**: ohos.permission.READ_IMAGEVIDEO or ohos.permission.WRITE_IMAGEVIDEO 1691 1692**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 1693 1694**Parameters** 1695 1696| Name | Type | Mandatory | Description | 1697| ---- | ------ | ---- | ----------------------------------- | 1698| mode | string | Yes | Mode for opening the file, which can be **'r'** (read-only), **'w'** (write-only), or **'rw'** (read/write).| 1699 1700**Return value** 1701 1702| Type | Description | 1703| --------------------- | ------------- | 1704| Promise<number> | Promise used to return the FD of the file opened.| 1705 1706**Error codes** 1707 1708For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 1709 1710| ID| Error Message| 1711| -------- | ---------------------------------------- | 1712| 202 | Called by non-system application. | 1713| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1714| 13900012 | Permission denied. | 1715| 13900020 | Invalid argument. | 1716| 14000011 | System inner fail. | 1717 1718**Example** 1719 1720```ts 1721async function example() { 1722 console.info('Open demo'); 1723 try { 1724 let testFileName: string = 'testFile' + Date.now() + '.jpg'; 1725 let photoAsset: photoAccessHelper.PhotoAsset = await phAccessHelper.createAsset(testFileName); 1726 let fd: number = await photoAsset.open('rw'); 1727 if (fd !== undefined) { 1728 console.info('File fd' + fd); 1729 photoAsset.close(fd); 1730 } else { 1731 console.error('Open file fail'); 1732 } 1733 } catch (err) { 1734 console.error(`Open demo err: ${err.code}, ${err.message}`); 1735 } 1736} 1737``` 1738 1739### setFavorite<sup>(deprecated)</sup> 1740 1741setFavorite(favoriteState: boolean, callback: AsyncCallback<void>): void 1742 1743Favorites or unfavorites this file. This API uses an asynchronous callback to return the result. 1744 1745> **NOTE** 1746> 1747> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.setFavorite](#setfavorite11) instead. 1748 1749**System API**: This is a system API. 1750 1751**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 1752 1753**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 1754 1755**Parameters** 1756 1757| Name | Type | Mandatory | Description | 1758| ---------- | ------------------------- | ---- | ---------------------------------- | 1759| favoriteState | boolean | Yes | Operation to perform. The value **true** means to favorite the file asset, and **false** means the opposite.| 1760| callback | AsyncCallback<void> | Yes | Callback that returns no value. | 1761 1762**Error codes** 1763 1764For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 1765 1766| ID| Error Message| 1767| -------- | ---------------------------------------- | 1768| 202 | Called by non-system application. | 1769| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1770| 13900012 | Permission denied. | 1771| 13900020 | Invalid argument. | 1772| 14000011 | System inner fail. | 1773 1774**Example** 1775 1776```ts 1777import { dataSharePredicates } from '@kit.ArkData'; 1778 1779async function example() { 1780 console.info('setFavoriteDemo'); 1781 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 1782 let fetchOption: photoAccessHelper.FetchOptions = { 1783 fetchColumns: [], 1784 predicates: predicates 1785 }; 1786 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 1787 let asset = await fetchResult.getFirstObject(); 1788 asset.setFavorite(true, (err) => { 1789 if (err === undefined) { 1790 console.info('favorite successfully'); 1791 } else { 1792 console.error(`favorite failed with error: ${err.code}, ${err.message}`); 1793 } 1794 }); 1795} 1796``` 1797 1798### setFavorite<sup>(deprecated)</sup> 1799 1800setFavorite(favoriteState: boolean): Promise<void> 1801 1802Favorites or unfavorites this file asset. This API uses a promise to return the result. 1803 1804> **NOTE** 1805> 1806> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.setFavorite](#setfavorite11) instead. 1807 1808**System API**: This is a system API. 1809 1810**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 1811 1812**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 1813 1814**Parameters** 1815 1816| Name | Type | Mandatory | Description | 1817| ---------- | ------- | ---- | ---------------------------------- | 1818| favoriteState | boolean | Yes | Operation to perform. The value **true** means to favorite the file asset, and **false** means the opposite.| 1819 1820**Return value** 1821 1822| Type | Description | 1823| ------------------- | ---------- | 1824| Promise<void> | Promise that returns no value.| 1825 1826**Error codes** 1827 1828For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 1829 1830| ID| Error Message| 1831| -------- | ---------------------------------------- | 1832| 202 | Called by non-system application. | 1833| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1834| 13900012 | Permission denied. | 1835| 13900020 | Invalid argument. | 1836| 14000011 | System inner fail. | 1837 1838**Example** 1839 1840```ts 1841import { dataSharePredicates } from '@kit.ArkData'; 1842import { BusinessError } from '@kit.BasicServicesKit'; 1843 1844async function example() { 1845 console.info('setFavoriteDemo'); 1846 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 1847 let fetchOption: photoAccessHelper.FetchOptions = { 1848 fetchColumns: [], 1849 predicates: predicates 1850 }; 1851 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 1852 let asset = await fetchResult.getFirstObject(); 1853 asset.setFavorite(true).then(() => { 1854 console.info('setFavorite successfully'); 1855 }).catch((err: BusinessError) => { 1856 console.error(`setFavorite failed with error: ${err.code}, ${err.message}`); 1857 }); 1858} 1859``` 1860 1861### setHidden<sup>(deprecated)</sup> 1862 1863setHidden(hiddenState: boolean, callback: AsyncCallback<void>): void 1864 1865Sets this file to hidden state. This API uses an asynchronous callback to return the result. 1866 1867Private files are stored in the private album. After obtaining private files from the private album, users can set **hiddenState** to **false** to remove them from the private album. 1868 1869> **NOTE** 1870> 1871> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.setHidden](#sethidden11) instead. 1872 1873**System API**: This is a system API. 1874 1875**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 1876 1877**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 1878 1879**Parameters** 1880 1881| Name | Type | Mandatory | Description | 1882| ---------- | ------------------------- | ---- | ---------------------------------- | 1883| hiddenState | boolean | Yes | Whether to set a file to hidden state. The value **true** means to hide the file; the value **false** means the opposite.| 1884| callback | AsyncCallback<void> | Yes | Callback that returns no value. | 1885 1886**Error codes** 1887 1888For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 1889 1890| ID| Error Message| 1891| -------- | ---------------------------------------- | 1892| 202 | Called by non-system application. | 1893| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1894| 13900012 | Permission denied. | 1895| 13900020 | Invalid argument. | 1896| 14000011 | System inner fail. | 1897 1898**Example** 1899 1900```ts 1901import { dataSharePredicates } from '@kit.ArkData'; 1902 1903async function example() { 1904 console.info('setHiddenDemo'); 1905 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 1906 let fetchOption: photoAccessHelper.FetchOptions = { 1907 fetchColumns: [], 1908 predicates: predicates 1909 }; 1910 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 1911 let asset = await fetchResult.getFirstObject(); 1912 asset.setHidden(true, (err) => { 1913 if (err === undefined) { 1914 console.info('setHidden successfully'); 1915 } else { 1916 console.error(`setHidden failed with error: ${err.code}, ${err.message}`); 1917 } 1918 }); 1919} 1920``` 1921 1922### setHidden<sup>(deprecated)</sup> 1923 1924setHidden(hiddenState: boolean): Promise<void> 1925 1926Sets this file asset to hidden state. This API uses a promise to return the result. 1927 1928Private files are stored in the private album. After obtaining private files from the private album, users can set **hiddenState** to **false** to remove them from the private album. 1929 1930> **NOTE** 1931> 1932> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.setHidden](#sethidden11) instead. 1933 1934**System API**: This is a system API. 1935 1936**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 1937 1938**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 1939 1940**Parameters** 1941 1942| Name | Type | Mandatory | Description | 1943| ---------- | ------- | ---- | ---------------------------------- | 1944| hiddenState | boolean | Yes | Whether to set a file to hidden state. The value **true** means to hide the file; the value **false** means the opposite.| 1945 1946**Return value** 1947 1948| Type | Description | 1949| ------------------- | ---------- | 1950| Promise<void> | Promise that returns no value.| 1951 1952**Error codes** 1953 1954For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 1955 1956| ID| Error Message| 1957| -------- | ---------------------------------------- | 1958| 202 | Called by non-system application. | 1959| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1960| 13900012 | Permission denied. | 1961| 13900020 | Invalid argument. | 1962| 14000011 | System inner fail. | 1963 1964**Example** 1965 1966```ts 1967import { dataSharePredicates } from '@kit.ArkData'; 1968import { BusinessError } from '@kit.BasicServicesKit'; 1969 1970async function example() { 1971 // Restore a file from a hidden album. Before the operation, ensure that the file exists in the hidden album. 1972 console.info('setHiddenDemo'); 1973 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 1974 let fetchOption: photoAccessHelper.FetchOptions = { 1975 fetchColumns: [], 1976 predicates: predicates 1977 }; 1978 let albumList: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.HIDDEN); 1979 let album = await albumList.getFirstObject(); 1980 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption); 1981 let asset = await fetchResult.getFirstObject(); 1982 asset.setHidden(false).then(() => { 1983 console.info('setHidden successfully'); 1984 }).catch((err: BusinessError) => { 1985 console.error(`setHidden failed with error: ${err.code}, ${err.message}`); 1986 }); 1987} 1988``` 1989 1990### getExif 1991 1992getExif(): Promise<string> 1993 1994Obtains the exchangeable image file format (EXIF) data from a JPG image. This API uses a promise to return the result. 1995 1996The EXIF information obtained are provided by the [image](../apis-image-kit/js-apis-image.md) module. For details about the EXIF information, see [image.PropertyKey](../apis-image-kit/js-apis-image.md#propertykey7). 1997 1998> **NOTE**<br>This API returns a JSON string consisting of EXIF tags. The complete EXIF information consists of **all_exif** and [PhotoKeys.USER_COMMENT](#photokeys). These two fields must be passed in via **fetchColumns**. 1999 2000**System API**: This is a system API. 2001 2002**Required permissions**: ohos.permission.READ_IMAGEVIDEO 2003 2004**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 2005 2006**Return value** 2007 2008| Type | Description | 2009| --------------------------------------- | ----------------- | 2010| Promise<string> | Promise used to return the EXIF data, in JSON strings.| 2011 2012**Error codes** 2013 2014For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 2015 2016| ID| Error Message| 2017| -------- | ---------------------------------------- | 2018| 202 | Called by non-system application. | 2019| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2020| 13900012 | Permission denied. | 2021| 13900020 | Invalid argument. | 2022| 14000011 | System inner fail. | 2023 2024**Example** 2025 2026```ts 2027import { dataSharePredicates } from '@kit.ArkData'; 2028 2029async function example() { 2030 try { 2031 console.info('getExifDemo'); 2032 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 2033 let fetchOptions: photoAccessHelper.FetchOptions = { 2034 fetchColumns: [ 'all_exif', photoAccessHelper.PhotoKeys.USER_COMMENT], 2035 predicates: predicates 2036 }; 2037 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions); 2038 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 2039 let exifMessage = await photoAsset.getExif(); 2040 let userCommentKey = 'UserComment'; 2041 let userComment = JSON.stringify(JSON.parse(exifMessage), [userCommentKey]); 2042 console.info('getExifDemo userComment: ' + JSON.stringify(userComment)); 2043 fetchResult.close(); 2044 } catch (err) { 2045 console.error(`getExifDemoCallback failed with error: ${err.code}, ${err.message}`); 2046 } 2047} 2048``` 2049 2050### getExif 2051 2052getExif(callback: AsyncCallback<string>): void 2053 2054Obtains the exchangeable image file format (EXIF) data from a JPG image. This API uses an asynchronous callback to return the result. 2055 2056The EXIF data obtained are provided by the [image](../apis-image-kit/js-apis-image.md) module. For details about the EXIF information, see [image.PropertyKey](../apis-image-kit/js-apis-image.md#propertykey7). 2057 2058> **NOTE**<br>This API returns a JSON string consisting of EXIF tags. The complete EXIF information consists of **all_exif** and [PhotoKeys.USER_COMMENT](#photokeys). These two fields must be passed in via **fetchColumns**. 2059 2060**System API**: This is a system API. 2061 2062**Required permissions**: ohos.permission.READ_IMAGEVIDEO 2063 2064**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 2065 2066**Parameters** 2067 2068| Name | Type | Mandatory| Description | 2069| -------- | ------------------------- | ---- | ---------- | 2070| callback | AsyncCallback<string> | Yes | Callback used to return the EXIF data, in JSON strings.| 2071 2072**Error codes** 2073 2074For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 2075 2076| ID| Error Message| 2077| -------- | ---------------------------------------- | 2078| 202 | Called by non-system application. | 2079| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2080| 13900012 | Permission denied. | 2081| 13900020 | Invalid argument. | 2082| 14000011 | System inner fail. | 2083 2084**Example** 2085 2086```ts 2087import { dataSharePredicates } from '@kit.ArkData'; 2088 2089async function example() { 2090 try { 2091 console.info('getExifDemo'); 2092 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 2093 predicates.isNotNull('all_exif') 2094 let fetchOptions: photoAccessHelper.FetchOptions = { 2095 fetchColumns: ['all_exif', photoAccessHelper.PhotoKeys.USER_COMMENT], 2096 predicates: predicates 2097 }; 2098 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions); 2099 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 2100 console.info('getExifDemo photoAsset displayName: ' + JSON.stringify(photoAsset.displayName)); 2101 let userCommentKey = 'UserComment'; 2102 photoAsset.getExif((err, exifMessage) => { 2103 if (exifMessage !== undefined) { 2104 let userComment = JSON.stringify(JSON.parse(exifMessage), [userCommentKey]); 2105 console.info('getExifDemo userComment: ' + JSON.stringify(userComment)); 2106 } else { 2107 console.error(`getExif failed, error: ${err.code}, ${err.message}`); 2108 } 2109 }); 2110 fetchResult.close(); 2111 } catch (err) { 2112 console.error(`getExifDemoCallback failed with error: ${err.code}, ${err.message}`); 2113 } 2114} 2115``` 2116 2117### setUserComment<sup>(deprecated)</sup> 2118 2119setUserComment(userComment: string): Promise<void> 2120 2121Sets user comment information of an image or video. This API uses a promise to return the result. 2122 2123> **NOTE** 2124> 2125> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.setUserComment](#setusercomment11) instead. 2126 2127**NOTE**<br>This API can be used to modify the comment information of only images or videos. 2128 2129**System API**: This is a system API. 2130 2131**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 2132 2133**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 2134 2135**Parameters** 2136 2137| Name | Type | Mandatory| Description | 2138| -------- | ------------------------- | ---- | ---------- | 2139| userComment | string | Yes | User comment information to set, which cannot exceed 420 characters.| 2140 2141**Return value** 2142 2143| Type | Description | 2144| --------------------------------------- | ----------------- | 2145|Promise<void> | Promise that returns no value.| 2146 2147**Error codes** 2148 2149For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 2150 2151| ID| Error Message| 2152| -------- | ---------------------------------------- | 2153| 202 | Called by non-system application. | 2154| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2155| 13900012 | Permission denied. | 2156| 13900020 | Invalid argument. | 2157| 14000011 | System inner fail. | 2158 2159**Example** 2160 2161```ts 2162import { dataSharePredicates } from '@kit.ArkData'; 2163 2164async function example() { 2165 try { 2166 console.info('setUserCommentDemo') 2167 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 2168 let fetchOptions: photoAccessHelper.FetchOptions = { 2169 fetchColumns: [], 2170 predicates: predicates 2171 }; 2172 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions); 2173 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 2174 let userComment = 'test_set_user_comment'; 2175 await photoAsset.setUserComment(userComment); 2176 } catch (err) { 2177 console.error(`setUserCommentDemoPromise failed with error: ${err.code}, ${err.message}`); 2178 } 2179} 2180``` 2181 2182### setUserComment<sup>(deprecated)</sup> 2183 2184setUserComment(userComment: string, callback: AsyncCallback<void>): void 2185 2186Sets user comment information of an image or video. This API uses an asynchronous callback to return the result. 2187 2188> **NOTE** 2189> 2190> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.setUserComment](#setusercomment11) instead. 2191 2192**NOTE**<br>This API can be used to modify the comment information of only images or videos. 2193 2194**System API**: This is a system API. 2195 2196**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 2197 2198**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 2199 2200**Parameters** 2201 2202| Name | Type | Mandatory| Description | 2203| -------- | ------------------------- | ---- | ---------- | 2204| userComment | string | Yes | User comment information to set, which cannot exceed 420 characters.| 2205| callback | AsyncCallback<void> | Yes | Callback that returns no value.| 2206 2207**Error codes** 2208 2209For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 2210 2211| ID| Error Message| 2212| -------- | ---------------------------------------- | 2213| 202 | Called by non-system application. | 2214| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2215| 13900012 | Permission denied. | 2216| 13900020 | Invalid argument. | 2217| 14000011 | System inner fail. | 2218 2219**Example** 2220 2221```ts 2222import { dataSharePredicates } from '@kit.ArkData'; 2223 2224async function example() { 2225 try { 2226 console.info('setUserCommentDemo') 2227 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 2228 let fetchOptions: photoAccessHelper.FetchOptions = { 2229 fetchColumns: [], 2230 predicates: predicates 2231 }; 2232 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions); 2233 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 2234 let userComment = 'test_set_user_comment'; 2235 photoAsset.setUserComment(userComment, (err) => { 2236 if (err === undefined) { 2237 console.info('setUserComment successfully'); 2238 } else { 2239 console.error(`setUserComment failed with error: ${err.code}, ${err.message}`); 2240 } 2241 }); 2242 } catch (err) { 2243 console.error(`setUserCommentDemoCallback failed with error: ${err.code}, ${err.message}`); 2244 } 2245} 2246``` 2247 2248### setPending<sup>11+</sup> 2249 2250setPending(pendingState: boolean, callback: AsyncCallback<void>): void 2251 2252Sets the pending state for this image or video asset. This API uses an asynchronous callback to return the result. 2253 2254The pending state can be removed only through **setPending(false)**. You can use **photoAsset.get(photoAccessHelper.PhotoKeys.PENDING)** to check whether the asset state is pending. If the asset is in pending state, **true** is returned. Otherwise, **false** is returned. 2255 2256**NOTE**<br>**setPending** can be used only during the file creation process. Once the FD is closed, **setPending(true)** cannot be used to set the pending state for the file. 2257 2258**System API**: This is a system API. 2259 2260**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 2261 2262**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 2263 2264**Parameters** 2265 2266| Name | Type | Mandatory | Description | 2267| ---------- | ------- | ---- | ---------------------------------- | 2268| pendingState | boolean | Yes | Whether to set the file to pending state. The value **true** means to set the file to pending state, and the value **false** means to remove the pending state.| 2269| callback | AsyncCallback<void> | Yes | Callback that returns no value.| 2270 2271**Error codes** 2272 2273For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 2274 2275| ID| Error Message| 2276| -------- | ---------------------------------------- | 2277| 201 | Permission denied. | 2278| 202 | Called by non-system application. | 2279| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2280| 14000011 | System inner fail. | 2281 2282**Example** 2283 2284```ts 2285async function example() { 2286 try { 2287 console.info('setPendingCallbackDemo'); 2288 let testFileName: string = 'testFile' + Date.now() + '.jpg'; 2289 let photoAsset = await phAccessHelper.createAsset(testFileName); 2290 let fd = await photoAsset.open('rw'); 2291 photoAsset.setPending(true, async (err) => { 2292 if (err !== undefined) { 2293 console.error(`setPending(true) failed with error: ${err.code}, ${err.message}`); 2294 return; 2295 } 2296 // write photo buffer in fd 2297 photoAsset.setPending(false, async (err) => { 2298 if (err !== undefined) { 2299 console.error(`setPending(false) failed with error: ${err.code}, ${err.message}`); 2300 return; 2301 } 2302 await photoAsset.close(fd); 2303 }); 2304 }); 2305 } catch (err) { 2306 console.error(`setPendingCallbackDemo failed with error: ${err.code}, ${err.message}`); 2307 } 2308} 2309``` 2310 2311### setPending<sup>11+</sup> 2312 2313setPending(pendingState: boolean): Promise<void> 2314 2315Sets the pending state for this image or video asset. This API uses a promise to return the result. 2316 2317The pending state can be removed only through **setPending(false)**. You can use **photoAsset.get(photoAccessHelper.PhotoKeys.PENDING)** to check whether the asset state is pending. If the asset is in pending state, **true** is returned. Otherwise, **false** is returned. 2318 2319**NOTE**<br>**setPending** can be used only during the file creation process. Once the FD is closed, **setPending(true)** cannot be used to set the pending state for the file. 2320 2321**System API**: This is a system API. 2322 2323**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 2324 2325**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 2326 2327**Parameters** 2328 2329| Name | Type | Mandatory | Description | 2330| ---------- | ------- | ---- | ---------------------------------- | 2331| pendingState | boolean | Yes | Whether to set the file to pending state. The value **true** means to set the file to pending state, and the value **false** means to remove the pending state.| 2332 2333**Return value** 2334 2335| Type | Description | 2336| --------------------------------------- | ----------------- | 2337|Promise<boolean> | Promise that returns no value.| 2338 2339**Error codes** 2340 2341For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 2342 2343| ID| Error Message| 2344| -------- | ---------------------------------------- | 2345| 201 | Permission denied. | 2346| 202 | Called by non-system application. | 2347| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2348| 14000011 | System inner fail. | 2349 2350**Example** 2351 2352```ts 2353async function example() { 2354 try { 2355 console.info('setPendingPromiseDemo'); 2356 let testFileName: string = 'testFile' + Date.now() + '.jpg'; 2357 let photoAsset = await phAccessHelper.createAsset(testFileName); 2358 let fd = await photoAsset.open('rw'); 2359 await photoAsset.setPending(true); 2360 // write photo buffer in fd 2361 photoAsset.setPending(false); 2362 await photoAsset.close(fd); 2363 } catch (err) { 2364 console.error(`setPendingPromiseDemo failed with error: ${err.code}, ${err.message}`); 2365 } 2366} 2367``` 2368 2369### isEdited<sup>11+</sup> 2370 2371isEdited(callback: AsyncCallback<boolean>): void 2372 2373Checks whether this image or video asset is edited. This API uses an asynchronous callback to return the result. 2374 2375**System API**: This is a system API. 2376 2377**Required permissions**: ohos.permission.READ_IMAGEVIDEO 2378 2379**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 2380 2381**Parameters** 2382 2383| Name | Type | Mandatory | Description | 2384| ---------- | ------- | ---- | ---------------------------------- | 2385| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.| 2386 2387**Error codes** 2388 2389For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 2390 2391| ID| Error Message| 2392| -------- | ---------------------------------------- | 2393| 201 | Permission denied. | 2394| 202 | Called by non-system application. | 2395| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2396| 14000011 | System inner fail. | 2397 2398**Example** 2399 2400```ts 2401import { dataSharePredicates } from '@kit.ArkData'; 2402 2403async function example() { 2404 try { 2405 console.info('isEditedCallbackDemo') 2406 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 2407 let fetchOptions: photoAccessHelper.FetchOptions = { 2408 fetchColumns: [], 2409 predicates: predicates 2410 }; 2411 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions); 2412 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 2413 photoAsset.isEdited((err, isEdited) => { 2414 if (err === undefined) { 2415 if (isEdited === true) { 2416 console.info('Photo is edited'); 2417 } else { 2418 console.info('Photo is not edited'); 2419 } 2420 } else { 2421 console.error(`isEdited failed with error: ${err.code}, ${err.message}`); 2422 } 2423 }); 2424 } catch (err) { 2425 console.error(`isEditedDemoCallback failed with error: ${err.code}, ${err.message}`); 2426 } 2427} 2428``` 2429 2430### isEdited<sup>11+</sup> 2431 2432isEdited(): Promise<boolean> 2433 2434Checks whether this image or video asset is edited. This API uses a promise to return the result. 2435 2436**System API**: This is a system API. 2437 2438**Required permissions**: ohos.permission.READ_IMAGEVIDEO 2439 2440**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 2441 2442**Return value** 2443 2444| Type | Description | 2445| --------------------------------------- | ----------------- | 2446|Promise<boolean> | Promise used to return the result.| 2447 2448 2449**Error codes** 2450 2451For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 2452 2453| ID| Error Message| 2454| -------- | ---------------------------------------- | 2455| 201 | Permission denied. | 2456| 202 | Called by non-system application. | 2457| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2458| 14000011 | System inner fail. | 2459 2460**Example** 2461 2462```ts 2463import { dataSharePredicates } from '@kit.ArkData'; 2464 2465async function example() { 2466 try { 2467 console.info('isEditedPromiseDemo') 2468 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 2469 let fetchOptions: photoAccessHelper.FetchOptions = { 2470 fetchColumns: [], 2471 predicates: predicates 2472 }; 2473 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions); 2474 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 2475 let isEdited = await photoAsset.isEdited(); 2476 if (isEdited === true) { 2477 console.info('Photo is edited'); 2478 } else { 2479 console.info('Photo is not edited'); 2480 } 2481 } catch (err) { 2482 console.error(`isEditedDemoCallback failed with error: ${err.code}, ${err.message}`); 2483 } 2484} 2485``` 2486 2487### requestEditData<sup>11+</sup> 2488 2489requestEditData(callback: AsyncCallback<string>): void 2490 2491Obtains the edit data of this image or video asset. This API uses an asynchronous callback to return the result. 2492 2493If the asset has never been edited, an empty string is returned. 2494 2495**System API**: This is a system API. 2496 2497**Required permissions**: ohos.permission.READ_IMAGEVIDEO 2498 2499**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 2500 2501**Parameters** 2502 2503| Name | Type | Mandatory | Description | 2504| ---------- | ------- | ---- | ---------------------------------- | 2505| callback | AsyncCallback<string> | Yes | Callback used to return the edit data obtained.| 2506 2507**Error codes** 2508 2509For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 2510 2511| ID| Error Message| 2512| -------- | ---------------------------------------- | 2513| 201 | Permission denied. | 2514| 202 | Called by non-system application. | 2515| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2516| 14000011 | System inner fail. | 2517 2518**Example** 2519 2520```ts 2521import { dataSharePredicates } from '@kit.ArkData'; 2522 2523async function example() { 2524 try { 2525 console.info('requestEditDataCallbackDemo') 2526 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 2527 let fetchOptions: photoAccessHelper.FetchOptions = { 2528 fetchColumns: [], 2529 predicates: predicates 2530 }; 2531 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions); 2532 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 2533 photoAsset.requestEditData((err, editdata) => { 2534 if (err === undefined) { 2535 console.info('Editdata is ' + editdata); 2536 } else { 2537 console.error(`requestEditData failed with error: ${err.code}, ${err.message}`); 2538 } 2539 }); 2540 } catch (err) { 2541 console.error(`requestEditDataCallbackDemo failed with error: ${err.code}, ${err.message}`); 2542 } 2543} 2544``` 2545 2546### requestEditData<sup>11+</sup> 2547 2548requestEditData(): Promise<string> 2549 2550Obtains the edit data of this image or video asset. This API uses a promise to return the result. 2551 2552If the asset has never been edited, an empty string is returned. 2553 2554**System API**: This is a system API. 2555 2556**Required permissions**: ohos.permission.READ_IMAGEVIDEO 2557 2558**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 2559 2560**Return value** 2561 2562| Type | Description | 2563| --------------------------------------- | ----------------- | 2564|Promise<string> | Promise used to return the edit data obtained.| 2565 2566 2567**Error codes** 2568 2569For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 2570 2571| ID| Error Message| 2572| -------- | ---------------------------------------- | 2573| 201 | Permission denied. | 2574| 202 | Called by non-system application. | 2575| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2576| 14000011 | System inner fail. | 2577 2578**Example** 2579 2580```ts 2581import { dataSharePredicates } from '@kit.ArkData'; 2582 2583async function example() { 2584 try { 2585 console.info('requestEditDataPromiseDemo') 2586 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 2587 let fetchOptions: photoAccessHelper.FetchOptions = { 2588 fetchColumns: [], 2589 predicates: predicates 2590 }; 2591 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions); 2592 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 2593 let editdata: string = await photoAsset.requestEditData(); 2594 console.info('Editdata is ' + editdata); 2595 } catch (err) { 2596 console.error(`requestEditDataPromiseDemo failed with error: ${err.code}, ${err.message}`); 2597 } 2598} 2599``` 2600 2601### getEditData<sup>11+</sup> 2602 2603getEditData(): Promise<MediaAssetEditData> 2604 2605Obtains the edited data of this asset. This API uses a promise to return the result. 2606 2607If the asset has never been edited, an empty string is returned. 2608 2609**System API**: This is a system API. 2610 2611**Required permissions**: ohos.permission.READ_IMAGEVIDEO 2612 2613**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 2614 2615**Return value** 2616 2617| Type | Description | 2618| --------------------------------------- | ----------------- | 2619|Promise<[MediaAssetEditData](#mediaasseteditdata11)> | Promise used to return the edited asset data.| 2620 2621**Error codes** 2622 2623For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 2624 2625| ID| Error Message| 2626| -------- | ---------------------------------------- | 2627| 201 | Permission denied. | 2628| 202 | Called by non-system application. | 2629| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2630| 14000011 | System inner fail. | 2631 2632**Example** 2633 2634```ts 2635import { dataSharePredicates } from '@kit.ArkData'; 2636 2637async function example() { 2638 try { 2639 console.info('getEditDataDemo') 2640 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 2641 let fetchOptions: photoAccessHelper.FetchOptions = { 2642 fetchColumns: [], 2643 predicates: predicates 2644 }; 2645 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions); 2646 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 2647 let assetEditData: photoAccessHelper.MediaAssetEditData = await photoAsset.getEditData(); 2648 let data: string = assetEditData.data; 2649 console.info('edit data is ' + data); 2650 } catch (err) { 2651 console.error(`getEditDataDemo failed with error: ${err.code}, ${err.message}`); 2652 } 2653} 2654``` 2655 2656### requestSource<sup>11+</sup> 2657 2658requestSource(callback: AsyncCallback<number>): void 2659 2660Opens the source file to obtain the FD. This API uses an asynchronous callback to return the result. 2661 2662**System API**: This is a system API. 2663 2664**Required permissions**: ohos.permission.READ_IMAGEVIDEO 2665 2666**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 2667 2668**Parameters** 2669 2670| Name | Type | Mandatory | Description | 2671| ---------- | ------- | ---- | ---------------------------------- | 2672| callback | AsyncCallback<number> | Yes | Callback used to return the FD.| 2673 2674**Error codes** 2675 2676For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 2677 2678| ID| Error Message| 2679| -------- | ---------------------------------------- | 2680| 201 | Permission denied. | 2681| 202 | Called by non-system application. | 2682| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2683| 14000011 | System inner fail. | 2684 2685**Example** 2686 2687```ts 2688import { dataSharePredicates } from '@kit.ArkData'; 2689 2690async function example() { 2691 try { 2692 console.info('requsetSourceCallbackDemo') 2693 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 2694 let fetchOptions: photoAccessHelper.FetchOptions = { 2695 fetchColumns: [], 2696 predicates: predicates 2697 }; 2698 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions); 2699 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 2700 photoAsset.requestSource((err, fd) => { 2701 if (err === undefined) { 2702 console.info('Source fd is ' + fd); 2703 } else { 2704 console.error(`requestSource failed with error: ${err.code}, ${err.message}`); 2705 } 2706 }); 2707 } catch (err) { 2708 console.error(`requsetSourceCallbackDemo failed with error: ${err.code}, ${err.message}`); 2709 } 2710} 2711``` 2712 2713### requestSource<sup>11+</sup> 2714 2715requestSource(): Promise<number> 2716 2717Opens the source file to obtain the FD. This API uses a promise to return the result. 2718 2719**System API**: This is a system API. 2720 2721**Required permissions**: ohos.permission.READ_IMAGEVIDEO 2722 2723**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 2724 2725**Return value** 2726 2727| Type | Description | 2728| --------------------------------------- | ----------------- | 2729|Promise<number> | Promise used to return the FD.| 2730 2731**Error codes** 2732 2733For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 2734 2735| ID| Error Message| 2736| -------- | ---------------------------------------- | 2737| 201 | Permission denied. | 2738| 202 | Called by non-system application. | 2739| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2740| 14000011 | System inner fail. | 2741 2742**Example** 2743 2744```ts 2745import { dataSharePredicates } from '@kit.ArkData'; 2746 2747async function example() { 2748 try { 2749 console.info('requsetSourcePromiseDemo') 2750 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 2751 let fetchOptions: photoAccessHelper.FetchOptions = { 2752 fetchColumns: [], 2753 predicates: predicates 2754 }; 2755 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions); 2756 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 2757 let fd = await photoAsset.requestSource(); 2758 console.info('Source fd is ' + fd); 2759 } catch (err) { 2760 console.error(`requsetSourcePromiseDemo failed with error: ${err.code}, ${err.message}`); 2761 } 2762} 2763``` 2764 2765### commitEditedAsset<sup>11+</sup> 2766 2767commitEditedAsset(editData: string, uri: string, callback: AsyncCallback<void>) 2768 2769Commits the edited image or video asset. This API uses an asynchronous callback to return the result. 2770 2771The edited file is transferred to the media library based on the URI, which is **FileUri** of the edited file in the application sandbox directory. For details, see [File URI](../apis-core-file-kit/js-apis-file-fileuri.md). 2772 2773**NOTE**<br>The commit operation overwrites the previous edited data. 2774 2775**System API**: This is a system API. 2776 2777**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 2778 2779**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 2780 2781**Parameters** 2782 2783| Name | Type | Mandatory | Description | 2784| ---------- | ------- | ---- | ---------------------------------- | 2785| editData | string | Yes | New data to commit.| 2786| uri | string | Yes | URI of the committed image or video in the application sandbox.| 2787| callback | AsyncCallback<void> | Yes | Callback that returns no value.| 2788 2789**Error codes** 2790 2791For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 2792 2793| ID| Error Message| 2794| -------- | ---------------------------------------- | 2795| 201 | Permission denied. | 2796| 202 | Called by non-system application. | 2797| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2798| 14000011 | System inner fail. | 2799 2800**Example** 2801 2802```ts 2803import { dataSharePredicates } from '@kit.ArkData'; 2804 2805async function example() { 2806 try { 2807 console.info('commitEditedAssetCallbackDemo') 2808 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 2809 let fetchOptions: photoAccessHelper.FetchOptions = { 2810 fetchColumns: [], 2811 predicates: predicates 2812 }; 2813 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions); 2814 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 2815 let editData = '123456'; 2816 let uri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg'; 2817 photoAsset.commitEditedAsset(editData, uri, (err) => { 2818 if (err === undefined) { 2819 console.info('commitEditedAsset is successful'); 2820 } else { 2821 console.error(`commitEditedAsset failed with error: ${err.code}, ${err.message}`); 2822 } 2823 }); 2824 } catch (err) { 2825 console.error(`commitEditedAssetCallbackDemo failed with error: ${err.code}, ${err.message}`); 2826 } 2827} 2828``` 2829 2830### commitEditedAsset<sup>11+</sup> 2831 2832commitEditedAsset(editData: string, uri: string): Promise<void> 2833 2834Commits the edited image or video asset. This API uses a promise to return the result. 2835 2836The edited file is transferred to the media library based on the URI, which is **FileUri** of the edited file in the application sandbox directory. For details, see [File URI](../apis-core-file-kit/js-apis-file-fileuri.md). 2837 2838**NOTE**<br>The commit operation overwrites the previous edited data. 2839 2840**System API**: This is a system API. 2841 2842**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 2843 2844**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 2845 2846**Parameters** 2847 2848| Name | Type | Mandatory | Description | 2849| ---------- | ------- | ---- | ---------------------------------- | 2850| editData | string | Yes | New data to commit.| 2851| uri | string | Yes | URI of the committed image or video in the application sandbox.| 2852 2853**Return value** 2854 2855| Type | Description | 2856| --------------------------------------- | ----------------- | 2857|Promise<void> | Promise that returns no value.| 2858 2859**Error codes** 2860 2861For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 2862 2863| ID| Error Message| 2864| -------- | ---------------------------------------- | 2865| 201 | Permission denied. | 2866| 202 | Called by non-system application. | 2867| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2868| 14000011 | System inner fail. | 2869 2870**Example** 2871 2872```ts 2873import { dataSharePredicates } from '@kit.ArkData'; 2874 2875async function example() { 2876 try { 2877 console.info('commitEditedAssetPromiseDemo') 2878 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 2879 let fetchOptions: photoAccessHelper.FetchOptions = { 2880 fetchColumns: [], 2881 predicates: predicates 2882 }; 2883 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions); 2884 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 2885 let editData = '123456'; 2886 let uri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg'; 2887 await photoAsset.commitEditedAsset(editData, uri); 2888 console.info('commitEditedAsset is successful'); 2889 } catch (err) { 2890 console.error(`commitEditedAssetPromiseDemo failed with error: ${err.code}, ${err.message}`); 2891 } 2892} 2893``` 2894 2895### revertToOriginal<sup>11+</sup> 2896 2897revertToOriginal(callback: AsyncCallback<void>) 2898 2899Reverts to the state of the file before being edited. This API uses an asynchronous callback to return the result. 2900 2901**NOTE**<br>This API deletes the edited data and edited image or video asset, and the deleted data cannot be restored. Exercise caution when using this API. 2902 2903**System API**: This is a system API. 2904 2905**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 2906 2907**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 2908 2909**Parameters** 2910 2911| Name | Type | Mandatory | Description | 2912| ---------- | ------- | ---- | ---------------------------------- | 2913| callback | AsyncCallback<void> | Yes | Callback that returns no value.| 2914 2915**Error codes** 2916 2917For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 2918 2919| ID| Error Message| 2920| -------- | ---------------------------------------- | 2921| 201 | Permission denied. | 2922| 202 | Called by non-system application. | 2923| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2924| 14000011 | System inner fail. | 2925 2926**Example** 2927 2928```ts 2929import { dataSharePredicates } from '@kit.ArkData'; 2930 2931async function example() { 2932 try { 2933 console.info('revertToOriginalCallbackDemo') 2934 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 2935 let fetchOptions: photoAccessHelper.FetchOptions = { 2936 fetchColumns: [], 2937 predicates: predicates 2938 }; 2939 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions); 2940 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 2941 photoAsset.revertToOriginal((err) => { 2942 if (err === undefined) { 2943 console.info('revertToOriginal is successful'); 2944 } else { 2945 console.error(`revertToOriginal failed with error: ${err.code}, ${err.message}`); 2946 } 2947 }); 2948 } catch (err) { 2949 console.error(`revertToOriginalCallbackDemo failed with error: ${err.code}, ${err.message}`); 2950 } 2951} 2952``` 2953 2954### revertToOriginal<sup>11+</sup> 2955 2956revertToOriginal(): Promise<void> 2957 2958Reverts to the state of the file before being edited. This API uses a promise to return the result. 2959 2960**NOTE**<br>This API deletes the edited data and edited image or video asset, and the deleted data cannot be restored. Exercise caution when using this API. 2961 2962**System API**: This is a system API. 2963 2964**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 2965 2966**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 2967 2968**Return value** 2969 2970| Type | Description | 2971| --------------------------------------- | ----------------- | 2972|Promise<string> | Promise that returns no value.| 2973 2974**Error codes** 2975 2976For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 2977 2978| ID| Error Message| 2979| -------- | ---------------------------------------- | 2980| 201 | Permission denied. | 2981| 202 | Called by non-system application. | 2982| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2983| 14000011 | System inner fail. | 2984 2985**Example** 2986 2987```ts 2988import { dataSharePredicates } from '@kit.ArkData'; 2989 2990async function example() { 2991 try { 2992 console.info('revertToOriginalPromiseDemo') 2993 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 2994 let fetchOptions: photoAccessHelper.FetchOptions = { 2995 fetchColumns: [], 2996 predicates: predicates 2997 }; 2998 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions); 2999 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 3000 photoAsset.revertToOriginal(); 3001 console.info('revertToOriginal is successful'); 3002 } catch (err) { 3003 console.error(`revertToOriginalPromiseDemo failed with error: ${err.code}, ${err.message}`); 3004 } 3005} 3006``` 3007 3008### requestPhoto<sup>11+</sup> 3009 3010requestPhoto(callback: AsyncCallback<image.PixelMap>): string 3011 3012Obtains the quick thumbnail and quality thumbnail of this asset. This API uses an asynchronous callback to return the result. 3013 3014The size of a quick thumbnail is 128 x 128, and the size of a quality thumbnail is 256 x 256. After this API is called, the callback will be invoked twice to return a quick thumbnail and a quality thumbnail in sequence. 3015 3016**System API**: This is a system API. 3017 3018**Required permissions**: ohos.permission.READ_IMAGEVIDEO 3019 3020**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 3021 3022**Parameters** 3023 3024| Name | Type | Mandatory | Description | 3025| ---------- | ------- | ---- | ---------------------------------- | 3026| callback | AsyncCallback<[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)> | Yes | Callback invoked twice to return the quick and quality thumbnails obtained.| 3027 3028**Return value** 3029 3030| Type | Description | 3031| --------------------------------------- | ----------------- | 3032| string | ID of the task for obtaining thumbnails.| 3033 3034**Error codes** 3035 3036For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 3037 3038| ID| Error Message| 3039| -------- | ---------------------------------------- | 3040| 201 | Permission verification failed, usually the result returned by VerifyAccessToken. | 3041| 202 | Permission verification failed, application which is not a system application uses system API. | 3042| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 3043| 14000011 | System inner fail. | 3044 3045**Example** 3046 3047```ts 3048import { dataSharePredicates } from '@kit.ArkData'; 3049import { image } from '@kit.ImageKit'; 3050 3051async function example() { 3052 try { 3053 console.info('requestPhotoDemo') 3054 let options: photoAccessHelper.FetchOptions = { 3055 fetchColumns: [], 3056 predicates: new dataSharePredicates.DataSharePredicates() 3057 } 3058 let fetchResult = await phAccessHelper.getAssets(options); 3059 let photoAsset = await fetchResult.getFirstObject(); 3060 let taskId: string = photoAsset.requestPhoto(async (err, pixel: image.PixelMap) => { 3061 if (err === undefined) { 3062 console.info("requestSource in, size: " + JSON.stringify((await pixel.getImageInfo()).size)) 3063 } else { 3064 console.error(`requestSource failed with error: ${err.code}, ${err.message}`); 3065 } 3066 }) 3067 console.info('requestSource taskId: ' + taskId) 3068 } catch (err) { 3069 console.error(`requestPhotoDemo failed with error: ${err.code}, ${err.message}`); 3070 } 3071} 3072``` 3073 3074### requestPhoto<sup>11+</sup> 3075 3076requestPhoto(options: RequestPhotoOptions, callback: AsyncCallback<image.PixelMap>): string 3077 3078Obtains the thumbnails of an asset based on the specified options. This API uses an asynchronous callback to return the result. 3079 3080**System API**: This is a system API. 3081 3082**Required permissions**: ohos.permission.READ_IMAGEVIDEO 3083 3084**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 3085 3086**Parameters** 3087 3088| Name | Type | Mandatory | Description | 3089| ---------- | ------- | ---- | ---------------------------------- | 3090| options | [RequestPhotoOptions](#requestphotooptions11) | Yes | Options for obtaining the asset thumbnail.| 3091| callback | AsyncCallback<[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)> | Yes | Callback used to return the thumbnails obtained. The callback may be invoked more than once, depending on **options**.| 3092 3093**Return value** 3094 3095| Type | Description | 3096| --------------------------------------- | ----------------- | 3097| string | ID of the task for obtaining thumbnails.| 3098 3099**Error codes** 3100 3101For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 3102 3103| ID| Error Message| 3104| -------- | ---------------------------------------- | 3105| 201 | Permission verification failed, usually the result returned by VerifyAccessToken. | 3106| 202 | Permission verification failed, application which is not a system application uses system API. | 3107| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 3108| 14000011 | System inner fail. | 3109 3110**Example** 3111 3112```ts 3113import { dataSharePredicates } from '@kit.ArkData'; 3114import { image } from '@kit.ImageKit'; 3115 3116async function example() { 3117 try { 3118 console.info('requestPhotoDemo') 3119 let options: photoAccessHelper.FetchOptions = { 3120 fetchColumns: [], 3121 predicates: new dataSharePredicates.DataSharePredicates() 3122 } 3123 let fetchResult = await phAccessHelper.getAssets(options); 3124 let photoAsset = await fetchResult.getFirstObject(); 3125 let taskId: string = photoAsset.requestPhoto({ 3126 "size": { 3127 "width": 256, 3128 "height": 256 3129 }, 3130 "requestPhotoType": photoAccessHelper.RequestPhotoType.REQUEST_ALL_THUMBNAILS 3131 }, async (err, pixel: image.PixelMap) => { 3132 if (err === undefined) { 3133 console.info("requestSource in, size: " + JSON.stringify((await pixel.getImageInfo()).size)) 3134 } else { 3135 console.error(`requestSource failed with error: ${err.code}, ${err.message}`); 3136 } 3137 }) 3138 console.info('requestSource taskId: ' + taskId) 3139 } catch (err) { 3140 console.error(`requestPhotoDemo failed with error: ${err.code}, ${err.message}`); 3141 } 3142} 3143``` 3144 3145### cancelPhotoRequest<sup>11+</sup> 3146 3147cancelPhotoRequest(requestId: string): void 3148 3149Cancels a task for obtaining media thumbnails. 3150 3151**System API**: This is a system API. 3152 3153**Required permissions**: ohos.permission.READ_IMAGEVIDEO 3154 3155**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 3156 3157**Parameters** 3158 3159| Name | Type | Mandatory | Description | 3160| ---------- | ------- | ---- | ---------------------------------- | 3161| requestId | string | Yes | ID of the task to cancel.| 3162 3163**Error codes** 3164 3165For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 3166 3167| ID| Error Message| 3168| -------- | ---------------------------------------- | 3169| 201 | Permission verification failed, usually the result returned by VerifyAccessToken. | 3170| 202 | Permission verification failed, application which is not a system application uses system API. | 3171| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 3172| 14000011 | System inner fail. | 3173 3174**Example** 3175 3176```ts 3177import { dataSharePredicates } from '@kit.ArkData'; 3178import { image } from '@kit.ImageKit'; 3179 3180async function example() { 3181 try { 3182 console.info('cancelPhotoRequestDemo') 3183 let options: photoAccessHelper.FetchOptions = { 3184 fetchColumns: [], 3185 predicates: new dataSharePredicates.DataSharePredicates() 3186 } 3187 let fetchResult = await phAccessHelper.getAssets(options); 3188 let photoAsset = await fetchResult.getFirstObject(); 3189 let taskId: string = photoAsset.requestPhoto({ 3190 "size": { 3191 "width": 256, 3192 "height": 256 3193 }, 3194 "requestPhotoType": photoAccessHelper.RequestPhotoType.REQUEST_ALL_THUMBNAILS 3195 }, async (err, pixel: image.PixelMap) => { 3196 if (err === undefined) { 3197 console.info("requestSource in, size: " + JSON.stringify((await pixel.getImageInfo()).size)) 3198 } else { 3199 console.error(`requestSource failed with error: ${err.code}, ${err.message}`); 3200 } 3201 }) 3202 console.info('requestSource taskId: ' + taskId) 3203 photoAsset.cancelPhotoRequest(taskId); 3204 } catch (err) { 3205 console.error(`cancelPhotoRequestDemo failed with error: ${err.code}, ${err.message}`); 3206 } 3207} 3208``` 3209 3210### getAnalysisData<sup>11+</sup> 3211 3212getAnalysisData(analysisType: AnalysisType): Promise\<string> 3213 3214Obtains analysis data. This API uses a promise to return the result. 3215 3216**System API**: This is a system API. 3217 3218**Required permissions**: ohos.permission.READ\_IMAGEVIDEO 3219 3220**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 3221 3222**Parameters** 3223 3224| Name | Type | Mandatory| Description | 3225| :----------- | :----------- | :- | :----------- | 3226| analysisType | [AnalysisType](#analysistype11) | Yes | Smart analysis type.| 3227 3228**Error codes** 3229 3230For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 3231 3232| ID | Error Message | 3233| :------- | :-------------------------------- | 3234| 201 | Permission denied. | 3235| 202 | Called by non-system application. | 3236| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 3237| 14000011 | System inner fail. | 3238 3239**Example** 3240 3241```ts 3242import { dataSharePredicates } from '@kit.ArkData'; 3243 3244async function example() { 3245 try { 3246 console.info('getAnalysisDataDemo') 3247 let fetchOptions: photoAccessHelper.FetchOptions = { 3248 fetchColumns: [], 3249 predicates: new dataSharePredicates.DataSharePredicates() 3250 } 3251 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = 3252 await phAccessHelper.getAssets(fetchOptions); 3253 let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 3254 if (photoAsset != undefined) { 3255 let analysisData: string = await photoAsset.getAnalysisData( 3256 photoAccessHelper.AnalysisType.ANALYSIS_OCR); 3257 console.info('get ocr result: ' + JSON.stringify(analysisData)); 3258 } 3259 fetchResult.close(); 3260 } catch (err) { 3261 console.error(`getAnalysisDataDemofailed with error: ${err.code}, ${err.message}`); 3262 } 3263} 3264``` 3265 3266## Album 3267 3268Provides APIs to manage albums. 3269 3270### recoverAssets<sup>(deprecated)</sup> 3271 3272recoverAssets(assets: Array<PhotoAsset>, callback: AsyncCallback<void>): void 3273 3274Recovers 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. 3275 3276> **NOTE** 3277> 3278> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.recoverAssets](#recoverassets11) instead. 3279 3280**System API**: This is a system API. 3281 3282**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 3283 3284**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 3285 3286**Parameters** 3287 3288| Name | Type | Mandatory| Description | 3289| -------- | ------------------------- | ---- | ---------- | 3290| assets | Array<[PhotoAsset](#photoasset)> | Yes | Array of the image or video assets to recover.| 3291| callback | AsyncCallback<void> | Yes | Callback that returns no value.| 3292 3293**Error codes** 3294 3295For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 3296 3297| ID| Error Message| 3298| -------- | ---------------------------------------- | 3299| 202 | Called by non-system application. | 3300| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 3301| 13900012 | Permission denied. | 3302| 13900020 | Invalid argument. | 3303| 14000011 | System inner fail. | 3304 3305**Example** 3306 3307```ts 3308import { dataSharePredicates } from '@kit.ArkData'; 3309 3310async function example() { 3311 try { 3312 console.info('recoverAssetsDemoCallback'); 3313 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 3314 let fetchOption: photoAccessHelper.FetchOptions = { 3315 fetchColumns: [], 3316 predicates: predicates 3317 }; 3318 let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH); 3319 let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject(); 3320 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption); 3321 let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 3322 album.recoverAssets([asset], (err) => { 3323 if (err === undefined) { 3324 console.info('album recoverAssets successfully'); 3325 } else { 3326 console.error(`album recoverAssets failed with error: ${err.code}, ${err.message}`); 3327 } 3328 }); 3329 } catch (err) { 3330 console.error(`recoverAssetsDemoCallback failed with error: ${err.code}, ${err.message}`); 3331 } 3332} 3333``` 3334 3335### recoverAssets<sup>(deprecated)</sup> 3336 3337recoverAssets(assets: Array<PhotoAsset>): Promise<void> 3338 3339Recovers 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. 3340 3341> **NOTE** 3342> 3343> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.recoverAssets](#recoverassets11) instead. 3344 3345**System API**: This is a system API. 3346 3347**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 3348 3349**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 3350 3351**Parameters** 3352 3353| Name | Type | Mandatory| Description | 3354| -------- | ------------------------- | ---- | ---------- | 3355| assets | Array<[PhotoAsset](#photoasset)> | Yes | Array of the image or video assets to recover.| 3356 3357**Return value** 3358 3359| Type | Description | 3360| --------------------------------------- | ----------------- | 3361|Promise<void> | Promise that returns no value.| 3362 3363**Error codes** 3364 3365For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 3366 3367| ID| Error Message| 3368| -------- | ---------------------------------------- | 3369| 202 | Called by non-system application. | 3370| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 3371| 13900012 | Permission denied. | 3372| 13900020 | Invalid argument. | 3373| 14000011 | System inner fail. | 3374 3375**Example** 3376 3377```ts 3378import { dataSharePredicates } from '@kit.ArkData'; 3379import { BusinessError } from '@kit.BasicServicesKit'; 3380 3381async function example() { 3382 try { 3383 console.info('recoverAssetsDemoPromise'); 3384 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 3385 let fetchOption: photoAccessHelper.FetchOptions = { 3386 fetchColumns: [], 3387 predicates: predicates 3388 }; 3389 let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH); 3390 let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject(); 3391 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption); 3392 let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 3393 album.recoverAssets([asset]).then(() => { 3394 console.info('album recoverAssets successfully'); 3395 }).catch((err: BusinessError) => { 3396 console.error(`album recoverAssets failed with error: ${err.code}, ${err.message}`); 3397 }); 3398 } catch (err) { 3399 console.error(`recoverAssetsDemoPromise failed with error: ${err.code}, ${err.message}`); 3400 } 3401} 3402``` 3403 3404### deleteAssets<sup>(deprecated)</sup> 3405 3406deleteAssets(assets: Array<PhotoAsset>, callback: AsyncCallback<void>): void 3407 3408Deletes 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. 3409 3410> **NOTE** 3411> 3412> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.deleteAssets](#deleteassets11) instead. 3413 3414**NOTE**<br>This operation is irreversible. The file assets deleted cannot be restored. Exercise caution when performing this operation. 3415 3416**System API**: This is a system API. 3417 3418**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 3419 3420**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 3421 3422**Parameters** 3423 3424| Name | Type | Mandatory| Description | 3425| -------- | ------------------------- | ---- | ---------- | 3426| assets | Array<[PhotoAsset](#photoasset)> | Yes | Array of the image or video assets to delete.| 3427| callback | AsyncCallback<void> | Yes | Callback that returns no value.| 3428 3429**Error codes** 3430 3431For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 3432 3433| ID| Error Message| 3434| -------- | ---------------------------------------- | 3435| 202 | Called by non-system application. | 3436| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 3437| 13900012 | Permission denied. | 3438| 13900020 | Invalid argument. | 3439| 14000011 | System inner fail. | 3440 3441**Example** 3442 3443```ts 3444import { dataSharePredicates } from '@kit.ArkData'; 3445 3446async function example() { 3447 try { 3448 console.info('deleteAssetsDemoCallback'); 3449 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 3450 let fetchOption: photoAccessHelper.FetchOptions = { 3451 fetchColumns: [], 3452 predicates: predicates 3453 }; 3454 let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH); 3455 let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject(); 3456 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption); 3457 let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 3458 album.deleteAssets([asset], (err) => { 3459 if (err === undefined) { 3460 console.info('album deleteAssets successfully'); 3461 } else { 3462 console.error(`album deleteAssets failed with error: ${err.code}, ${err.message}`); 3463 } 3464 }); 3465 } catch (err) { 3466 console.error(`deleteAssetsDemoCallback failed with error: ${err.code}, ${err.message}`); 3467 } 3468} 3469``` 3470 3471### deleteAssets<sup>(deprecated)</sup> 3472 3473deleteAssets(assets: Array<PhotoAsset>): Promise<void> 3474 3475Deletes 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. 3476 3477> **NOTE** 3478> 3479> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.deleteAssets](#deleteassets11) instead. 3480 3481**NOTE**<br>This operation is irreversible. The file assets deleted cannot be restored. Exercise caution when performing this operation. 3482 3483**System API**: This is a system API. 3484 3485**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 3486 3487**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 3488 3489**Parameters** 3490 3491| Name | Type | Mandatory| Description | 3492| -------- | ------------------------- | ---- | ---------- | 3493| assets | Array<[PhotoAsset](#photoasset)> | Yes | Array of the image or video assets to delete.| 3494 3495**Return value** 3496 3497| Type | Description | 3498| --------------------------------------- | ----------------- | 3499|Promise<void> | Promise that returns no value.| 3500 3501**Error codes** 3502 3503For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 3504 3505| ID| Error Message| 3506| -------- | ---------------------------------------- | 3507| 202 | Called by non-system application. | 3508| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 3509| 13900012 | Permission denied. | 3510| 13900020 | Invalid argument. | 3511| 14000011 | System inner fail. | 3512 3513**Example** 3514 3515```ts 3516import { dataSharePredicates } from '@kit.ArkData'; 3517import { BusinessError } from '@kit.BasicServicesKit'; 3518 3519async function example() { 3520 try { 3521 console.info('deleteAssetsDemoPromise'); 3522 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 3523 let fetchOption: photoAccessHelper.FetchOptions = { 3524 fetchColumns: [], 3525 predicates: predicates 3526 }; 3527 let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH); 3528 let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject(); 3529 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption); 3530 let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 3531 album.deleteAssets([asset]).then(() => { 3532 console.info('album deleteAssets successfully'); 3533 }).catch((err: BusinessError) => { 3534 console.error(`album deleteAssets failed with error: ${err.code}, ${err.message}`); 3535 }); 3536 } catch (err) { 3537 console.error(`deleteAssetsDemoPromise failed with error: ${err.code}, ${err.message}`); 3538 } 3539} 3540``` 3541 3542### setCoverUri<sup>(deprecated)</sup> 3543 3544setCoverUri(uri: string, callback: AsyncCallback<void>): void 3545 3546Sets the album cover. This API uses an asynchronous callback to return the result. 3547 3548> **NOTE** 3549> 3550> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.setCoverUri](#setcoveruri11) instead. 3551 3552**NOTE**<br>This API can be used to set the user album cover, but not the system album cover. 3553 3554**System API**: This is a system API. 3555 3556**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 3557 3558**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 3559 3560**Parameters** 3561 3562| Name | Type | Mandatory| Description | 3563| -------- | ------------------------- | ---- | ---------- | 3564| uri | string | Yes | URI of the file to be set as the album cover.| 3565| callback | AsyncCallback<void> | Yes | Callback that returns no value.| 3566 3567**Error codes** 3568 3569For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 3570 3571| ID| Error Message| 3572| -------- | ---------------------------------------- | 3573| 202 | Called by non-system application. | 3574| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 3575| 13900012 | Permission denied. | 3576| 13900020 | Invalid argument. | 3577| 14000011 | System inner fail. | 3578 3579**Example** 3580 3581```ts 3582import { dataSharePredicates } from '@kit.ArkData'; 3583 3584async function example() { 3585 try { 3586 console.info('setCoverUriDemoCallback'); 3587 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 3588 let fetchOption: photoAccessHelper.FetchOptions = { 3589 fetchColumns: [], 3590 predicates: predicates 3591 }; 3592 let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC); 3593 let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject(); 3594 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption); 3595 let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 3596 album.setCoverUri(asset.uri, (err) => { 3597 if (err === undefined) { 3598 console.info('album setCoverUri successfully'); 3599 } else { 3600 console.error(`album setCoverUri failed with error: ${err.code}, ${err.message}`); 3601 } 3602 }); 3603 } catch (err) { 3604 console.error(`setCoverUriDemoCallback failed with error: ${err.code}, ${err.message}`); 3605 } 3606} 3607``` 3608 3609### setCoverUri<sup>(deprecated)</sup> 3610 3611setCoverUri(uri: string): Promise<void> 3612 3613Sets the album cover. This API uses a promise to return the result. 3614 3615> **NOTE** 3616> 3617> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.setCoverUri](#setcoveruri11) instead. 3618 3619**NOTE**<br>This API can be used to set the user album cover, but not the system album cover. 3620 3621**System API**: This is a system API. 3622 3623**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 3624 3625**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 3626 3627**Parameters** 3628 3629| Name | Type | Mandatory| Description | 3630| -------- | ------------------------- | ---- | ---------- | 3631| uri | string | Yes | URI of the file to be set as the album cover.| 3632 3633**Return value** 3634 3635| Type | Description | 3636| --------------------------------------- | ----------------- | 3637|Promise<void> | Promise that returns no value.| 3638 3639**Error codes** 3640 3641For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 3642 3643| ID| Error Message| 3644| -------- | ---------------------------------------- | 3645| 202 | Called by non-system application. | 3646| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 3647| 13900012 | Permission denied. | 3648| 13900020 | Invalid argument. | 3649| 14000011 | System inner fail. | 3650**Example** 3651 3652```ts 3653import { dataSharePredicates } from '@kit.ArkData'; 3654import { BusinessError } from '@kit.BasicServicesKit'; 3655 3656async function example() { 3657 try { 3658 console.info('setCoverUriDemoPromise'); 3659 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 3660 let fetchOption: photoAccessHelper.FetchOptions = { 3661 fetchColumns: [], 3662 predicates: predicates 3663 }; 3664 let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC); 3665 let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject(); 3666 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption); 3667 let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 3668 album.setCoverUri(asset.uri).then(() => { 3669 console.info('album setCoverUri successfully'); 3670 }).catch((err: BusinessError) => { 3671 console.error(`album setCoverUri failed with error: ${err.code}, ${err.message}`); 3672 }); 3673 } catch (err) { 3674 console.error(`setCoverUriDemoPromise failed with error: ${err.code}, ${err.message}`); 3675 } 3676} 3677``` 3678 3679## MediaAssetEditData<sup>11+</sup> 3680 3681Represents the edited media asset data. 3682 3683**System API**: This is a system API. 3684 3685**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 3686 3687### Properties 3688 3689| Name | Type | Readable | Writable | Description | 3690| ------------ | ------ | ---- | ---- | ------- | 3691| compatibleFormat | string | Yes | Yes | Format of the edited data. <br>**System API**: This is a system API. | 3692| formatVersion | string | Yes | Yes | Version of the data format. <br>**System API**: This is a system API. | 3693| data | string | Yes | Yes | Content edited. <br>**System API**: This is a system API. | 3694 3695### constructor<sup>11+</sup> 3696 3697constructor(compatibleFormat: string, formatVersion: string) 3698 3699Constructor. 3700 3701**System API**: This is a system API. 3702 3703**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 3704 3705**Parameters** 3706 3707| Name | Type | Mandatory| Description | 3708| -------- | ------------------------- | ---- | ---------- | 3709| compatibleFormat | string | Yes | Format of the edited data.| 3710| formatVersion | string | Yes | Version of the data format.| 3711 3712**Error codes** 3713 3714For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 3715 3716| ID| Error Message| 3717| -------- | ---------------------------------------- | 3718| 202 | Called by non-system application. | 3719| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 3720| 14000011 | System inner fail. | 3721 3722**Example** 3723 3724```ts 3725let assetEditData: photoAccessHelper.MediaAssetEditData = new photoAccessHelper.MediaAssetEditData('system', '1.0'); 3726``` 3727 3728## MediaAssetChangeRequest<sup>11+</sup> 3729 3730Represents a media asset change request. 3731 3732**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 3733 3734### createAssetRequest<sup>11+</sup> 3735 3736static createAssetRequest(context: Context, displayName: string, options?: PhotoCreateOptions): MediaAssetChangeRequest 3737 3738Creates an asset change request with the specified file name. 3739 3740The file name must comply with the following specifications: 3741- The file name consists of a valid file name and an image or video file name extension. 3742- The file name cannot exceed 255 characters. 3743- The file name cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ] 3744 3745**System API**: This is a system API. 3746 3747**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 3748 3749**Parameters** 3750 3751| Name | Type | Mandatory| Description | 3752| ------- | ------- | ---- | -------------------------- | 3753| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes | Context of the ability instance.| 3754| displayName | string | Yes | File name of the image or video to create. | 3755| options | [PhotoCreateOptions](#photocreateoptions) | No | Options for creating an image or video asset. | 3756 3757**Return value** 3758 3759| Type | Description | 3760| --------------------------------------- | ----------------- | 3761| [MediaAssetChangeRequest](#mediaassetchangerequest11) | **MediaAssetChangeRequest** created.| 3762 3763**Error codes** 3764 3765For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 3766 3767| ID| Error Message| 3768| -------- | ---------------------------------------- | 3769| 202 | Called by non-system application. | 3770| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 3771| 14000001 | Invalid display name. | 3772| 14000011 | System inner fail. | 3773 3774**Example** 3775 3776```ts 3777async function example() { 3778 console.info('createAssetRequestDemo'); 3779 try { 3780 let testFileName: string = 'testFile' + Date.now() + '.jpg'; 3781 let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createAssetRequest(context, testFileName); 3782 // Ensure that the asset specified by fileUri exists. 3783 let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg'; 3784 assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, fileUri); 3785 await phAccessHelper.applyChanges(assetChangeRequest); 3786 console.info('apply createAssetRequest successfully'); 3787 } catch (err) { 3788 console.error(`createAssetRequestDemo failed with error: ${err.code}, ${err.message}`); 3789 } 3790} 3791``` 3792 3793### setFavorite<sup>11+</sup> 3794 3795setFavorite(favoriteState: boolean): void 3796 3797Favorites or unfavorites this file. 3798 3799**System API**: This is a system API. 3800 3801**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 3802 3803**Parameters** 3804 3805| Name | Type | Mandatory | Description | 3806| ---------- | ------- | ---- | ---------------------------------- | 3807| favoriteState | boolean | Yes | Operation to perform. The value **true** means to favorite the file, and **false** means the opposite.| 3808 3809**Error codes** 3810 3811For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 3812 3813| ID| Error Message| 3814| -------- | ---------------------------------------- | 3815| 202 | Called by non-system application. | 3816| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 3817| 14000011 | System inner fail. | 3818 3819**Example** 3820 3821```ts 3822import { dataSharePredicates } from '@kit.ArkData'; 3823import { BusinessError } from '@kit.BasicServicesKit'; 3824 3825async function example() { 3826 console.info('setFavoriteDemo'); 3827 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 3828 let fetchOption: photoAccessHelper.FetchOptions = { 3829 fetchColumns: [], 3830 predicates: predicates 3831 }; 3832 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 3833 let asset = await fetchResult.getFirstObject(); 3834 let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset); 3835 assetChangeRequest.setFavorite(true); 3836 phAccessHelper.applyChanges(assetChangeRequest).then(() => { 3837 console.info('apply setFavorite successfully'); 3838 }).catch((err: BusinessError) => { 3839 console.error(`apply setFavorite failed with error: ${err.code}, ${err.message}`); 3840 }); 3841} 3842``` 3843 3844### setHidden<sup>11+</sup> 3845 3846setHidden(hiddenState: boolean): void 3847 3848Hides this file. 3849 3850**System API**: This is a system API. 3851 3852**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 3853 3854**Parameters** 3855 3856| Name | Type | Mandatory | Description | 3857| ---------- | ------- | ---- | ---------------------------------- | 3858| hiddenState | boolean | Yes | Whether to hide the file. The value **true** means to hide the file; the value **false** means the opposite.| 3859 3860**Error codes** 3861 3862For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 3863 3864| ID| Error Message| 3865| -------- | ---------------------------------------- | 3866| 202 | Called by non-system application. | 3867| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 3868| 14000011 | System inner fail. | 3869 3870**Example** 3871 3872```ts 3873import { dataSharePredicates } from '@kit.ArkData'; 3874import { BusinessError } from '@kit.BasicServicesKit'; 3875 3876async function example() { 3877 console.info('setHiddenDemo'); 3878 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 3879 let fetchOption: photoAccessHelper.FetchOptions = { 3880 fetchColumns: [], 3881 predicates: predicates 3882 }; 3883 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 3884 let asset = await fetchResult.getFirstObject(); 3885 let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset); 3886 assetChangeRequest.setHidden(true); 3887 phAccessHelper.applyChanges(assetChangeRequest).then(() => { 3888 console.info('apply setHidden successfully'); 3889 }).catch((err: BusinessError) => { 3890 console.error(`apply setHidden failed with error: ${err.code}, ${err.message}`); 3891 }); 3892} 3893``` 3894 3895### setUserComment<sup>11+</sup> 3896 3897setUserComment(userComment: string): void 3898 3899Sets the user comment information of this media asset. 3900 3901**System API**: This is a system API. 3902 3903**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 3904 3905**Parameters** 3906 3907| Name | Type | Mandatory | Description | 3908| ---------- | ------- | ---- | ---------------------------------- | 3909| userComment | string | Yes | Comment information to set, which cannot exceed 420 characters.| 3910 3911**Error codes** 3912 3913For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 3914 3915| ID| Error Message| 3916| -------- | ---------------------------------------- | 3917| 202 | Called by non-system application. | 3918| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 3919| 14000011 | System inner fail. | 3920 3921**Example** 3922 3923```ts 3924import { dataSharePredicates } from '@kit.ArkData'; 3925import { BusinessError } from '@kit.BasicServicesKit'; 3926 3927async function example() { 3928 console.info('setUserCommentDemo'); 3929 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 3930 let fetchOption: photoAccessHelper.FetchOptions = { 3931 fetchColumns: [], 3932 predicates: predicates 3933 }; 3934 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 3935 let asset = await fetchResult.getFirstObject(); 3936 let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset); 3937 let userComment: string = 'test_set_user_comment'; 3938 assetChangeRequest.setUserComment(userComment); 3939 phAccessHelper.applyChanges(assetChangeRequest).then(() => { 3940 console.info('apply setUserComment successfully'); 3941 }).catch((err: BusinessError) => { 3942 console.error(`apply setUserComment failed with error: ${err.code}, ${err.message}`); 3943 }); 3944} 3945``` 3946 3947### setEditData<sup>11+</sup> 3948 3949setEditData(editData: MediaAssetEditData): void 3950 3951Saves the edited data of an asset. 3952 3953**System API**: This is a system API. 3954 3955**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 3956 3957**Parameters** 3958 3959| Name | Type | Mandatory | Description | 3960| ---------- | ------- | ---- | ---------------------------------- | 3961| editData | [MediaAssetEditData](#mediaasseteditdata11) | Yes | Edited data to save.| 3962 3963**Error codes** 3964 3965For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 3966 3967| ID| Error Message| 3968| -------- | ---------------------------------------- | 3969| 202 | Called by non-system application. | 3970| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 3971| 14000011 | System inner fail. | 3972 3973**Example** 3974 3975```ts 3976import { dataSharePredicates } from '@kit.ArkData'; 3977import { BusinessError } from '@kit.BasicServicesKit'; 3978 3979async function example() { 3980 console.info('setEditDataDemo'); 3981 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 3982 let fetchOption: photoAccessHelper.FetchOptions = { 3983 fetchColumns: [], 3984 predicates: predicates 3985 }; 3986 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 3987 let asset = await fetchResult.getFirstObject(); 3988 let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset); 3989 3990 let assetEditData: photoAccessHelper.MediaAssetEditData = new photoAccessHelper.MediaAssetEditData('system', '1.0'); 3991 let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg'; 3992 assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, fileUri); 3993 assetEditData.data = '123456'; 3994 assetChangeRequest.setEditData(assetEditData); 3995 phAccessHelper.applyChanges(assetChangeRequest).then(() => { 3996 console.info('apply setEditData successfully'); 3997 }).catch((err: BusinessError) => { 3998 console.error(`apply setEditData failed with error: ${err.code}, ${err.message}`); 3999 }); 4000} 4001``` 4002 4003### addResource<sup>11+</sup> 4004 4005addResource(type: ResourceType, proxy: PhotoProxy): void 4006 4007Adds resources using **PhotoProxy** data. 4008 4009> **NOTE**<br>For the same asset change request, this API cannot be repeatedly called after resources are successfully added. 4010 4011**System API**: This is a system API available only for camera applications. 4012 4013**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4014 4015**Parameters** 4016 4017| Name | Type | Mandatory| Description | 4018| ------- |---------------------------------| ---- |----------------------| 4019| type | [ResourceType](#resourcetype11) | Yes | Type of the resource to add. | 4020| proxy | [PhotoProxy](#photoproxy11) | Yes | PhotoProxy data of the resource to add.| 4021 4022**Error codes** 4023 4024For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 4025 4026| ID | Error Message | 4027|----------|-----------------------------------| 4028| 202 | Called by non-system application. | 4029| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 4030| 14000011 | System inner fail. | 4031| 14000016 | Operation Not Support. | 4032 4033**Example** 4034 4035```ts 4036class PhotoProxyImpl implements photoAccessHelper.PhotoProxy { 4037 // Implement PhotoProxy. 4038} 4039 4040async function example() { 4041 console.info('addResourceByPhotoProxyDemo'); 4042 try { 4043 let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE; 4044 let extension: string = 'jpg'; 4045 let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createAssetRequest(context, photoType, extension); 4046 let photoProxy: PhotoProxyImpl = new PhotoProxyImpl(); 4047 assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, photoProxy); 4048 await phAccessHelper.applyChanges(assetChangeRequest); 4049 console.info('addResourceByPhotoProxy successfully'); 4050 } catch (err) { 4051 console.error(`addResourceByPhotoProxyDemo failed with error: ${err.code}, ${err.message}`); 4052 } 4053} 4054``` 4055 4056### setLocation<sup>11+</sup> 4057 4058setLocation(longitude: number, latitude: number): void 4059 4060Sets location information. 4061 4062**System API**: This is a system API. 4063 4064**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4065 4066**Parameters** 4067 4068| Name | Type | Mandatory| Description | 4069| ------- |-------------| ---- |-------| 4070| longitude | number | Yes | Longitude.| 4071| latitude | number | Yes | Latitude. | 4072 4073**Error codes** 4074 4075For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 4076 4077| ID| Error Message| 4078| -------- | ---------------------------------------- | 4079| 202 | Called by non-system application. | 4080| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 4081| 14000011 | System inner fail. | 4082 4083**Example** 4084 4085```ts 4086import { dataSharePredicates } from '@kit.ArkData'; 4087import { BusinessError } from '@kit.BasicServicesKit'; 4088 4089async function example() { 4090 console.info('setLocationDemo'); 4091 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 4092 let fetchOption: photoAccessHelper.FetchOptions = { 4093 fetchColumns: [], 4094 predicates: predicates 4095 }; 4096 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 4097 let asset = await fetchResult.getFirstObject(); 4098 let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset); 4099 assetChangeRequest.setLocation(120.52, 30.40); 4100 phAccessHelper.applyChanges(assetChangeRequest).then(() => { 4101 console.info('apply setLocation successfully'); 4102 }).catch((err: BusinessError) => { 4103 console.error(`apply setLocation failed with error: ${err.code}, ${err.message}`); 4104 }); 4105} 4106``` 4107 4108### setCameraShotKey<sup>12+</sup> 4109 4110setCameraShotKey(cameraShotKey: string): void 4111 4112Sets the Key for the Ultra Snapshot feature, which allows the camera to take photos or record videos with the screen off. 4113 4114**System API**: This is a system API. 4115 4116**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4117 4118**Parameters** 4119 4120| Name | Type | Mandatory | Description | 4121| ---------- | ------- | ---- | ---------------------------------- | 4122| cameraShotKey | string | Yes | Key for the Ultra Snapshot feature.<br>This parameter is available only for the system camera, and the key value is defined by the system camera.| 4123 4124**Error codes** 4125 4126For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 4127 4128| ID| Error Message| 4129| -------- | ---------------------------------------- | 4130| 202 | Called by non-system application. | 4131| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 4132| 14000011 | System inner fail. | 4133 4134**Example** 4135 4136```ts 4137async function example(asset: photoAccessHelper.PhotoAsset) { 4138 console.info('setCameraShotKeyDemo'); 4139 try { 4140 let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset); 4141 let cameraShotKey: string = 'test_MediaAssetChangeRequest_setCameraShotKey'; 4142 assetChangeRequest.setCameraShotKey(cameraShotKey); 4143 await phAccessHelper.applyChanges(assetChangeRequest); 4144 console.info('apply setCameraShotKey successfully'); 4145 } catch (err) { 4146 console.error(`apply setCameraShotKey failed with error: ${err.code}, ${err.message}`); 4147 } 4148} 4149``` 4150 4151### setEffectMode<sup>12+</sup> 4152 4153setEffectMode(mode: MovingPhotoEffectMode): void 4154 4155Sets the effect of this moving photo. 4156 4157**System API**: This is a system API. 4158 4159**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4160 4161**Parameters** 4162 4163| Name | Type | Mandatory | Description | 4164| ---------- | ------- | ---- | ---------------------------------- | 4165| mode | [MovingPhotoEffectMode](#movingphotoeffectmode12) | Yes | Effect to set.| 4166 4167**Error codes** 4168 4169For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 4170 4171| ID| Error Message| 4172| -------- | ---------------------------------------- | 4173| 202 | Called by non-system application. | 4174| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 4175| 14000011 | System inner fail. | 4176| 14000016 | Operation Not Support. | 4177 4178**Example** 4179 4180```ts 4181async function example(asset: photoAccessHelper.PhotoAsset) { 4182 console.info('setEffectModeDemo'); 4183 try { 4184 let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset); 4185 assetChangeRequest.setEffectMode(photoAccessHelper.MovingPhotoEffectMode.LONG_EXPOSURE); 4186 // Ensure that the asset specified by fileUri exists. 4187 let imageFileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/long_exposure.jpg'; 4188 let videoFileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/long_exposure.mp4'; 4189 assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, imageFileUri); 4190 assetChangeRequest.addResource(photoAccessHelper.ResourceType.VIDEO_RESOURCE, videoFileUri); 4191 await phAccessHelper.applyChanges(assetChangeRequest); 4192 console.info('apply setEffectMode successfully'); 4193 } catch (err) { 4194 console.error(`apply setEffectMode failed with error: ${err.code}, ${err.message}`); 4195 } 4196} 4197``` 4198 4199### setSupportedWatermarkType<sup>14+</sup> 4200 4201setSupportedWatermarkType(watermarkType: WatermarkType): void 4202 4203Sets the watermark type supported by photos. 4204 4205**System API**: This is a system API. 4206 4207**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4208 4209**Parameters** 4210 4211| Name | Type | Mandatory | Description | 4212| ---------- | ------- | ---- | ---------------------------------- | 4213| watermarkType | [WatermarkType](#watermarktype14) | Yes | Watermark type to set. | 4214 4215**Error codes** 4216 4217For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 4218 4219| ID| Error Message| 4220| -------- | ---------------------------------------- | 4221| 202 | Called by non-system application. | 4222| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 4223| 14000011 | Internal system error. | 4224 4225**Example** 4226 4227```ts 4228import { dataSharePredicates } from '@kit.ArkData'; 4229import photoAccessHelper from '@ohos.file.photoAccessHelper'; 4230 4231const context = getContext(this); 4232let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context); 4233 4234async function example() { 4235 console.info('setSupportedWatermarkTypeDemo'); 4236 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 4237 let fetchOption: photoAccessHelper.FetchOptions = { 4238 fetchColumns: [], 4239 predicates: predicates 4240 }; 4241 try { 4242 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 4243 let asset = await fetchResult.getFirstObject(); 4244 let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset); 4245 assetChangeRequest.setSupportedWatermarkType(photoAccessHelper.WatermarkType.BRAND_COMMON); 4246 await phAccessHelper.applyChanges(assetChangeRequest); 4247 console.info('apply setSupportedWatermarkType successfully'); 4248 } catch (err) { 4249 console.error(`apply setSupportedWatermarkType failed with error: ${err.code}, ${err.message}`); 4250 } 4251} 4252``` 4253 4254## MediaAssetsChangeRequest<sup>11+</sup> 4255 4256Represents a request for changing multiple assets. 4257 4258**System API**: This is a system API. 4259 4260**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4261 4262### constructor<sup>11+</sup> 4263 4264constructor(assets: Array<PhotoAsset>) 4265 4266Constructor. 4267 4268**System API**: This is a system API. 4269 4270**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4271 4272**Parameters** 4273 4274| Name | Type | Mandatory| Description | 4275| -------- | ------------------------- | ---- | ---------- | 4276| assets | Array<[PhotoAsset](#photoasset)> | Yes | Assets to change.| 4277 4278**Error codes** 4279 4280For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 4281 4282| ID| Error Message| 4283| -------- | ---------------------------------------- | 4284| 202 | Called by non-system application. | 4285| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 4286| 14000011 | System inner fail. | 4287 4288**Example** 4289 4290```ts 4291import { dataSharePredicates } from '@kit.ArkData'; 4292 4293async function example() { 4294 console.info('MediaAssetsChangeRequest constructorDemo'); 4295 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 4296 let fetchOption: photoAccessHelper.FetchOptions = { 4297 fetchColumns: [], 4298 predicates: predicates 4299 }; 4300 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 4301 let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects(); 4302 let assetsChangeRequest: photoAccessHelper.MediaAssetsChangeRequest = new photoAccessHelper.MediaAssetsChangeRequest(photoAssetList); 4303} 4304``` 4305 4306### setFavorite<sup>11+</sup> 4307 4308setFavorite(favoriteState: boolean): void 4309 4310Favorites or unfavorites this file. 4311 4312**System API**: This is a system API. 4313 4314**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4315 4316**Parameters** 4317 4318| Name | Type | Mandatory | Description | 4319| ---------- | ------- | ---- | ---------------------------------- | 4320| favoriteState | boolean | Yes | Operation to perform. The value **true** means to favorite the file, and **false** means the opposite.| 4321 4322**Error codes** 4323 4324For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 4325 4326| ID| Error Message| 4327| -------- | ---------------------------------------- | 4328| 202 | Called by non-system application. | 4329| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 4330| 14000011 | System inner fail. | 4331 4332**Example** 4333 4334```ts 4335import { dataSharePredicates } from '@kit.ArkData'; 4336import { BusinessError } from '@kit.BasicServicesKit'; 4337 4338async function example() { 4339 console.info('setFavoriteDemo'); 4340 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 4341 let fetchOption: photoAccessHelper.FetchOptions = { 4342 fetchColumns: [], 4343 predicates: predicates 4344 }; 4345 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 4346 let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects(); 4347 let assetsChangeRequest: photoAccessHelper.MediaAssetsChangeRequest = new photoAccessHelper.MediaAssetsChangeRequest(photoAssetList); 4348 assetsChangeRequest.setFavorite(true); 4349 phAccessHelper.applyChanges(assetsChangeRequest).then(() => { 4350 console.info('apply setFavorite successfully'); 4351 }).catch((err: BusinessError) => { 4352 console.error(`apply setFavorite failed with error: ${err.code}, ${err.message}`); 4353 }); 4354} 4355``` 4356 4357### setHidden<sup>11+</sup> 4358 4359setHidden(hiddenState: boolean): void 4360 4361Hides this file. 4362 4363**System API**: This is a system API. 4364 4365**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4366 4367**Parameters** 4368 4369| Name | Type | Mandatory | Description | 4370| ---------- | ------- | ---- | ---------------------------------- | 4371| hiddenState | boolean | Yes | Whether to hide the file. The value **true** means to hide the file; the value **false** means the opposite.| 4372 4373**Error codes** 4374 4375For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 4376 4377| ID| Error Message| 4378| -------- | ---------------------------------------- | 4379| 202 | Called by non-system application. | 4380| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 4381| 14000011 | System inner fail. | 4382 4383**Example** 4384 4385```ts 4386import { dataSharePredicates } from '@kit.ArkData'; 4387import { BusinessError } from '@kit.BasicServicesKit'; 4388 4389async function example() { 4390 console.info('setHiddenDemo'); 4391 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 4392 let fetchOption: photoAccessHelper.FetchOptions = { 4393 fetchColumns: [], 4394 predicates: predicates 4395 }; 4396 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 4397 let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects(); 4398 let assetsChangeRequest: photoAccessHelper.MediaAssetsChangeRequest = new photoAccessHelper.MediaAssetsChangeRequest(photoAssetList); 4399 assetsChangeRequest.setHidden(true); 4400 phAccessHelper.applyChanges(assetsChangeRequest).then(() => { 4401 console.info('apply setHidden successfully'); 4402 }).catch((err: BusinessError) => { 4403 console.error(`apply setHidden failed with error: ${err.code}, ${err.message}`); 4404 }); 4405} 4406``` 4407 4408### setUserComment<sup>11+</sup> 4409 4410setUserComment(userComment: string): void 4411 4412Sets the user comment information of this media asset. 4413 4414**System API**: This is a system API. 4415 4416**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4417 4418**Parameters** 4419 4420| Name | Type | Mandatory | Description | 4421| ---------- | ------- | ---- | ---------------------------------- | 4422| userComment | string | Yes | Comment information to set, which cannot exceed 420 characters.| 4423 4424**Error codes** 4425 4426For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 4427 4428| ID| Error Message| 4429| -------- | ---------------------------------------- | 4430| 202 | Called by non-system application. | 4431| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 4432| 14000011 | System inner fail. | 4433 4434**Example** 4435 4436```ts 4437import { dataSharePredicates } from '@kit.ArkData'; 4438import { BusinessError } from '@kit.BasicServicesKit'; 4439 4440async function example() { 4441 console.info('setUserCommentDemo'); 4442 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 4443 let fetchOption: photoAccessHelper.FetchOptions = { 4444 fetchColumns: [], 4445 predicates: predicates 4446 }; 4447 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption); 4448 let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects(); 4449 let assetsChangeRequest: photoAccessHelper.MediaAssetsChangeRequest = new photoAccessHelper.MediaAssetsChangeRequest(photoAssetList); 4450 assetsChangeRequest.setUserComment('test_set_user_comment'); 4451 phAccessHelper.applyChanges(assetsChangeRequest).then(() => { 4452 console.info('apply setUserComment successfully'); 4453 }).catch((err: BusinessError) => { 4454 console.error(`apply setUserComment failed with error: ${err.code}, ${err.message}`); 4455 }); 4456} 4457``` 4458 4459## MediaAlbumChangeRequest<sup>11+</sup> 4460 4461Provides APIs for managing the media album change request. 4462 4463**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4464 4465### createAlbumRequest<sup>11+</sup> 4466 4467static createAlbumRequest(context: Context, name: string): MediaAlbumChangeRequest 4468 4469Creates a **MediaAlbumChangeRequest** instance. 4470 4471The album name must comply with the following specifications: 4472- The album name cannot exceed 255 characters. 4473- The album name cannot contain any of the following characters:<br>. .. \ / : * ? " ' ` < > | { } [ ] 4474- The album name is case-insensitive. 4475- Duplicate album names are not allowed. 4476 4477**System API**: This is a system API. 4478 4479**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4480 4481**Parameters** 4482 4483| Name | Type | Mandatory| Description | 4484| ------- | ------- | ---- | -------------------------- | 4485| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes | Context of the ability instance.| 4486| name | string | Yes | Name of the album.| 4487 4488**Return value** 4489 4490| Type | Description | 4491| --------------------------------------- | ----------------- | 4492| [MediaAlbumChangeRequest](#mediaalbumchangerequest11) | **MediaAlbumChangeRequest** instance created.| 4493 4494**Error codes** 4495 4496For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 4497 4498| ID| Error Message| 4499| -------- | ---------------------------------------- | 4500| 202 | Called by non-system application. | 4501| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 4502| 14000011 | System inner fail. | 4503 4504**Example** 4505 4506```ts 4507async function example() { 4508 console.info('createAlbumRequestDemo'); 4509 try { 4510 let albumName: string = 'newAlbumName' + new Date().getTime(); 4511 let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = photoAccessHelper.MediaAlbumChangeRequest.createAlbumRequest(context, albumName); 4512 await phAccessHelper.applyChanges(albumChangeRequest); 4513 console.info('apply createAlbumRequest successfully'); 4514 } catch (err) { 4515 console.error(`createAlbumRequestDemo failed with error: ${err.code}, ${err.message}`); 4516 } 4517} 4518``` 4519 4520### deleteAlbums<sup>11+</sup> 4521 4522static deleteAlbums(context: Context, albums: Array<Album>): Promise<void> 4523 4524Deletes albums. This API uses a promise to return the result. 4525 4526Ensure that the albums to be deleted exist. Only user albums can be deleted. 4527 4528**System API**: This is a system API. 4529 4530**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO 4531 4532**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4533 4534**Parameters** 4535 4536| Name | Type | Mandatory| Description | 4537| ------- | ------- | ---- | -------------------------- | 4538| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes | Context of the ability instance.| 4539| albums | Array<[Album](#album)> | Yes | Albums to delete. | 4540 4541**Return value** 4542 4543| Type | Description | 4544| --------------------------------------- | ----------------- | 4545| Promise<void>| Promise that returns no value.| 4546 4547**Error codes** 4548 4549For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 4550 4551| ID| Error Message| 4552| -------- | ---------------------------------------- | 4553| 201 | Permission denied. | 4554| 202 | Called by non-system application. | 4555| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 4556| 14000011 | System inner fail. | 4557 4558**Example** 4559 4560```ts 4561import { dataSharePredicates } from '@kit.ArkData'; 4562 4563async function example() { 4564 console.info('deleteAlbumsDemo'); 4565 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 4566 let fetchOptions: photoAccessHelper.FetchOptions = { 4567 fetchColumns: [], 4568 predicates: predicates 4569 }; 4570 try { 4571 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions); 4572 let album: photoAccessHelper.Album = await fetchResult.getFirstObject(); 4573 await photoAccessHelper.MediaAlbumChangeRequest.deleteAlbums(context, [album]); 4574 console.info('deleteAlbums successfully'); 4575 } catch (err) { 4576 console.error(`deleteAlbumsDemo failed with error: ${err.code}, ${err.message}`); 4577 } 4578} 4579``` 4580 4581### setCoverUri<sup>11+</sup> 4582 4583setCoverUri(coverUri: string): void 4584 4585Sets the album cover. 4586 4587**System API**: This is a system API. 4588 4589**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4590 4591**Parameters** 4592 4593| Name | Type | Mandatory | Description | 4594| ---------- | ------- | ---- | ---------------------------------- | 4595| coverUri | string | Yes | URI of the file to be set as the album cover.| 4596 4597**Error codes** 4598 4599For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 4600 4601| ID| Error Message| 4602| -------- | ---------------------------------------- | 4603| 202 | Called by non-system application. | 4604| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 4605| 14000011 | System inner fail. | 4606 4607**Example** 4608 4609```ts 4610import { dataSharePredicates } from '@kit.ArkData'; 4611 4612async function example() { 4613 console.info('setCoverUriDemo'); 4614 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 4615 let fetchOptions: photoAccessHelper.FetchOptions = { 4616 fetchColumns: [], 4617 predicates: predicates 4618 }; 4619 try { 4620 let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC); 4621 let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject(); 4622 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions); 4623 let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 4624 4625 let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album); 4626 albumChangeRequest.setCoverUri(asset.uri); 4627 await phAccessHelper.applyChanges(albumChangeRequest); 4628 console.info('setCoverUri successfully'); 4629 } catch (err) { 4630 console.error(`setCoverUriDemo failed with error: ${err.code}, ${err.message}`); 4631 } 4632} 4633``` 4634 4635### moveAssets<sup>11+</sup> 4636 4637moveAssets(assets: Array<PhotoAsset>, targetAlbum: Album): void 4638 4639Moves assets to another album. 4640 4641**System API**: This is a system API. 4642 4643**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4644 4645**Parameters** 4646 4647| Name | Type | Mandatory | Description | 4648| ---------- | ------- | ---- | ---------------------------------- | 4649| assets | Array<[PhotoAsset](#photoasset)> | Yes | Assets to move.| 4650| targetAlbum | Album | Yes | Album to which the assets are to be moved.| 4651 4652**Error codes** 4653 4654For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 4655 4656| ID| Error Message| 4657| -------- | ---------------------------------------- | 4658| 202 | Called by non-system application. | 4659| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 4660| 14000011 | System inner fail. | 4661| 14000016 | Operation Not Support. | 4662 4663**Example** 4664 4665```ts 4666import { dataSharePredicates } from '@kit.ArkData'; 4667 4668async function example() { 4669 console.info('moveAssetsDemo'); 4670 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 4671 let fetchOptions: photoAccessHelper.FetchOptions = { 4672 fetchColumns: [], 4673 predicates: predicates 4674 }; 4675 try { 4676 let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC); 4677 let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject(); 4678 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions); 4679 let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 4680 4681 if (albumFetchResult.isAfterLast()) { 4682 console.error('lack of album to be moved into'); 4683 return; 4684 } 4685 let nextAlbum: photoAccessHelper.Album = await albumFetchResult.getNextObject(); 4686 let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album); 4687 albumChangeRequest.moveAssets([asset], nextAlbum); 4688 await phAccessHelper.applyChanges(albumChangeRequest); 4689 console.info('moveAssets successfully'); 4690 } catch (err) { 4691 console.error(`moveAssetsDemo failed with error: ${err.code}, ${err.message}`); 4692 } 4693} 4694``` 4695 4696### recoverAssets<sup>11+</sup> 4697 4698recoverAssets(assets: Array<PhotoAsset>): void 4699 4700Recovers assets from the trash. 4701 4702**System API**: This is a system API. 4703 4704**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4705 4706**Parameters** 4707 4708| Name | Type | Mandatory | Description | 4709| ---------- | ------- | ---- | ---------------------------------- | 4710| assets | Array<[PhotoAsset](#photoasset)> | Yes | Assets to recover.| 4711 4712**Error codes** 4713 4714For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 4715 4716| ID| Error Message| 4717| -------- | ---------------------------------------- | 4718| 202 | Called by non-system application. | 4719| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 4720| 14000011 | System inner fail. | 4721| 14000016 | Operation Not Support. | 4722 4723**Example** 4724 4725```ts 4726import { dataSharePredicates } from '@kit.ArkData'; 4727 4728async function example() { 4729 console.info('recoverAssetsDemo'); 4730 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 4731 let fetchOptions: photoAccessHelper.FetchOptions = { 4732 fetchColumns: [], 4733 predicates: predicates 4734 }; 4735 try { 4736 let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH); 4737 let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject(); 4738 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions); 4739 let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 4740 4741 let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album); 4742 albumChangeRequest.recoverAssets([asset]); 4743 await phAccessHelper.applyChanges(albumChangeRequest); 4744 console.info('recoverAssets successfully'); 4745 } catch (err) { 4746 console.error(`recoverAssetsDemo failed with error: ${err.code}, ${err.message}`); 4747 } 4748} 4749``` 4750 4751### deleteAssets<sup>11+</sup> 4752 4753deleteAssets(assets: Array<PhotoAsset>): void 4754 4755Permanently deletes assets from the trash. 4756 4757**NOTE**<br>This operation is irreversible. The file assets deleted cannot be restored. Exercise caution when performing this operation. 4758 4759**System API**: This is a system API. 4760 4761**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4762 4763**Parameters** 4764 4765| Name | Type | Mandatory | Description | 4766| ---------- | ------- | ---- | ---------------------------------- | 4767| assets | Array<[PhotoAsset](#photoasset)> | Yes | Assets to be permanently deleted.| 4768 4769**Error codes** 4770 4771For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 4772 4773| ID| Error Message| 4774| -------- | ---------------------------------------- | 4775| 202 | Called by non-system application. | 4776| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 4777| 14000011 | System inner fail. | 4778| 14000016 | Operation Not Support. | 4779 4780**Example** 4781 4782```ts 4783import { dataSharePredicates } from '@kit.ArkData'; 4784 4785async function example() { 4786 console.info('deleteAssetsPermanentlyDemo'); 4787 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 4788 let fetchOptions: photoAccessHelper.FetchOptions = { 4789 fetchColumns: [], 4790 predicates: predicates 4791 }; 4792 try { 4793 let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH); 4794 let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject(); 4795 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions); 4796 let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject(); 4797 4798 let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album); 4799 albumChangeRequest.deleteAssets([asset]); 4800 await phAccessHelper.applyChanges(albumChangeRequest); 4801 console.info('succeed to deleteAssets permanently'); 4802 } catch (err) { 4803 console.error(`deleteAssetsPermanentlyDemo failed with error: ${err.code}, ${err.message}`); 4804 } 4805} 4806``` 4807 4808### setDisplayLevel<sup>11+</sup> 4809 4810setDisplayLevel(displayLevel: number): void 4811 4812Sets the display level of the portrait album. 4813 4814**System API**: This is a system API. 4815 4816**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4817 4818**Parameters** 4819 4820| Name | Type | Mandatory | Description | 4821| ---------- | ------- | ---- | ---------------------------------- | 4822| displayLevel | number | Yes | Display level to set.<br>The options are as follows:<br>**0**: unfavorite the portrait album.<br>**1**: set the portrait album as the first to display.<br>**2**: do not display the portrait album as the first one.<br>**3**: favorite the portrait album.| 4823 4824**Error codes** 4825 4826For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 4827 4828| ID| Error Message| 4829| -------- | ---------------------------------------- | 4830| 202 | Called by non-system application. | 4831| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 4832| 14000011 | System inner fail. | 4833 4834**Example** 4835 4836``` ts 4837import { dataSharePredicates } from '@kit.ArkData'; 4838 4839async function example() { 4840 try { 4841 console.info('setDisplayLevel Example') 4842 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 4843 predicates.equalTo('user_display_level', 2); 4844 let fetchOptions: photoAccessHelper.FetchOptions = { 4845 fetchColumns: [], 4846 predicates: predicates 4847 }; 4848 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.PORTRAIT, fetchOptions); 4849 let album: photoAccessHelper.Album = await fetchResult.getFirstObject(); 4850 let changeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album); 4851 changeRequest.setDisplayLevel(1); 4852 await phAccessHelper.applyChanges(changeRequest); 4853 } catch (err) { 4854 console.error(`setDisplayLevel failed with error: ${err.code}, ${err.message}`); 4855 } 4856} 4857``` 4858 4859### setIsMe<sup>11+</sup> 4860 4861setIsMe(): void 4862 4863Sets the relationship between people in the portrait album to **Me**. 4864 4865**System API**: This is a system API. 4866 4867**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4868 4869**Error codes** 4870 4871For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 4872 4873| ID| Error Message| 4874| -------- | ---------------------------------------- | 4875| 202 | Called by non-system application. | 4876| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 4877| 14000011 | System inner fail. | 4878 4879**Example** 4880 4881``` ts 4882import { dataSharePredicates } from '@kit.ArkData'; 4883 4884async function example() { 4885 try { 4886 console.info('setIsMe Example') 4887 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 4888 predicates.equalTo('user_display_level', 2); 4889 let fetchOptions: photoAccessHelper.FetchOptions = { 4890 fetchColumns: [], 4891 predicates: predicates 4892 }; 4893 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.PORTRAIT, fetchOptions); 4894 let album: photoAccessHelper.Album = await fetchResult.getFirstObject(); 4895 let changeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album); 4896 changeRequest.setIsMe(); 4897 await phAccessHelper.applyChanges(changeRequest); 4898 } catch (err) { 4899 console.error(`setIsMe failed with error: ${err.code}, ${err.message}`); 4900 } 4901} 4902``` 4903 4904### dismissAssets<sup>11+</sup> 4905 4906dismissAssets(assets: Array<PhotoAsset>): void 4907 4908Removes assets from this portrait album or group photo album. 4909 4910**System API**: This is a system API. 4911 4912**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4913 4914**Parameters** 4915 4916| Name | Type | Mandatory | Description | 4917| ---------- | ------- | ---- | ---------------------------------- | 4918| assets | Array<PhotoAsset> | Yes | Assets to remove.| 4919 4920**Error codes** 4921 4922For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 4923 4924| ID| Error Message| 4925| -------- | ---------------------------------------- | 4926| 202 | Called by non-system application. | 4927| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 4928| 14000011 | System inner fail. | 4929| 14000016 | Operation Not support. | 4930 4931**Example** 4932 4933``` ts 4934import { dataSharePredicates } from '@kit.ArkData'; 4935 4936async function example() { 4937 try { 4938 console.info('dismissAssets Example') 4939 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 4940 predicates.equalTo('user_display_level', 2); 4941 let fetchOptions: photoAccessHelper.FetchOptions = { 4942 fetchColumns: [], 4943 predicates: predicates 4944 }; 4945 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.PORTRAIT, fetchOptions); 4946 let album: photoAccessHelper.Album = await fetchResult.getFirstObject(); 4947 4948 let predicatesAsset: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 4949 let assetFetchOptions: photoAccessHelper.FetchOptions = { 4950 fetchColumns: [], 4951 predicates: predicatesAsset 4952 }; 4953 let assetFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(assetFetchOptions); 4954 let asset: photoAccessHelper.PhotoAsset = await assetFetchResult.getFirstObject(); 4955 4956 let changeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album); 4957 changeRequest.dismissAssets([asset]); 4958 await phAccessHelper.applyChanges(changeRequest); 4959 } catch (err) { 4960 console.error(`dismissAssets failed with error: ${err.code}, ${err.message}`); 4961 } 4962} 4963``` 4964 4965### mergeAlbum<sup>11+</sup> 4966 4967mergeAlbum(target: Album): void 4968 4969Merges two portrait albums. 4970 4971**System API**: This is a system API. 4972 4973**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 4974 4975**Parameters** 4976 4977| Name | Type | Mandatory | Description | 4978| ---------- | ------- | ---- | ---------------------------------- | 4979| target | [Album](#album) | Yes | Album generated after the merge. The album must be renamed.| 4980 4981**Error codes** 4982 4983For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 4984 4985| ID| Error Message| 4986| -------- | ---------------------------------------- | 4987| 202 | Called by non-system application. | 4988| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 4989| 14000011 | System inner fail. | 4990| 14000016 | Operation Not support. | 4991 4992**Example** 4993 4994``` ts 4995import { dataSharePredicates } from '@kit.ArkData'; 4996 4997async function example() { 4998 try { 4999 console.info('mergeAlbum Example') 5000 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 5001 predicates.equalTo('user_display_level', 2); 5002 let fetchOptions: photoAccessHelper.FetchOptions = { 5003 fetchColumns: [], 5004 predicates: predicates 5005 }; 5006 let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.PORTRAIT, fetchOptions); 5007 let album: photoAccessHelper.Album = await fetchResult.getFirstObject(); 5008 if (fetchResult.isAfterLast()) { 5009 console.error('lack of album to merge'); 5010 return; 5011 } 5012 let target: photoAccessHelper.Album = await fetchResult.getNextObject(); 5013 5014 let changeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album); 5015 changeRequest.mergeAlbum(target); 5016 changeRequest.setAlbumName("testName"); 5017 await phAccessHelper.applyChanges(changeRequest); 5018 } catch (err) { 5019 console.error(`mergeAlbum failed with error: ${err.code}, ${err.message}`); 5020 } 5021} 5022``` 5023 5024### placeBefore<sup>11+</sup> 5025 5026placeBefore(album: Album): void; 5027 5028Places this album before an album. 5029 5030**System API**: This is a system API. 5031 5032**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5033 5034**Parameters** 5035 5036| Name | Type | Mandatory | Description | 5037| ---------- | ------- | ---- | ---------------------------------- | 5038| album | [Album](#album) | Yes | Target album. To place this album to the end, set **album** to null.| 5039 5040**Error codes** 5041 5042For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 5043 5044| ID| Error Message| 5045| -------- | ---------------------------------------- | 5046| 202 | Called by non-system application. | 5047| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5048| 14000011 | System inner fail. | 5049 5050**Example** 5051 5052```ts 5053async function example() { 5054 console.info('placeBeforeDemo'); 5055 try { 5056 let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC); 5057 let firstAlbum: photoAccessHelper.Album = await albumFetchResult.getFirstObject(); 5058 if (albumFetchResult.isAfterLast()) { 5059 console.error('lack of album to place before'); 5060 return; 5061 } 5062 let secondAlbum: photoAccessHelper.Album = await albumFetchResult.getNextObject(); 5063 let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(secondAlbum); 5064 albumChangeRequest.placeBefore(firstAlbum); 5065 await phAccessHelper.applyChanges(albumChangeRequest); 5066 console.info('placeBefore successfully'); 5067 } catch (err) { 5068 console.error(`placeBeforeDemo failed with error: ${err.code}, ${err.message}`); 5069 } 5070} 5071``` 5072 5073### dismiss<sup>13+</sup> 5074 5075dismiss(): void 5076 5077Removes this group photo album. 5078 5079**System API**: This is a system API. 5080 5081**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5082 5083**Error codes** 5084 5085For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 5086 5087| ID | Error Message | 5088| :------- | :-------------------------------- | 5089| 202 | Called by non-system application. | 5090| 401 | Parameter error. Possible causes: Incorrect parameter types. | 5091| 14000011 | System inner fail. | 5092 5093**Example** 5094 5095```ts 5096import { dataSharePredicates } from '@kit.ArkData'; 5097 5098async function example() { 5099 console.info('dismissDemo'); 5100 try { 5101 let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.GROUP_PHOTO); 5102 let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject(); 5103 5104 let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album); 5105 albumChangeRequest.dismiss(); 5106 await phAccessHelper.applyChanges(albumChangeRequest); 5107 console.info('dismiss successfully'); 5108 } catch (err) { 5109 console.error(`dismissDemo failed with error: ${err.code}, ${err.message}`); 5110 } 5111} 5112``` 5113 5114## HighlightAlbum<sup>12+</sup> 5115 5116Provides APIs for managing the **Highlights** album, which is an automatically generated collection of memorable photos or videos. 5117 5118**System API**: This is a system API. 5119 5120**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5121 5122### constructor<sup>12+</sup> 5123 5124constructor(album: Album) 5125 5126A constructor used to create a **Highlights** album instance. 5127 5128**System API**: This is a system API. 5129 5130**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5131 5132**Parameters** 5133 5134| Name | Type | Mandatory| Description | 5135| -------- | ------------------------- | ---- | ---------- | 5136| album | [Album](#album) | Yes | **Highlights** album to create.| 5137 5138**Error codes** 5139 5140For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 5141 5142| ID| Error Message| 5143| -------- | ---------------------------------------- | 5144| 202 | Called by non-system application. | 5145| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5146| 14000011 | Internal system error. | 5147 5148**Example** 5149 5150```ts 5151import { dataSharePredicates } from '@kit.ArkData'; 5152 5153async function example() { 5154 console.info('HighlightAlbum constructorDemo'); 5155 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 5156 let fetchOption: photoAccessHelper.FetchOptions = { 5157 fetchColumns: [], 5158 predicates: predicates 5159 }; 5160 let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await photoAccessHelper.getAlbums( 5161 photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.HIGHLIGHT, fetchOption); 5162 let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject(); 5163 let highlightAlbum: photoAccessHelper.HighlightAlbum = new photoAccessHelper.HighlightAlbum(album); 5164 albumFetchResult.close(); 5165} 5166``` 5167 5168### getHighlightAlbumInfo<sup>12+</sup> 5169 5170getHighlightAlbumInfo(type: HighlightAlbumInfoType): Promise<string> 5171 5172Obtains specific information about the **Highlights** album. 5173 5174**System API**: This is a system API. 5175 5176**Required permissions**: ohos.permission.READ\_IMAGEVIDEO 5177 5178**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5179 5180**Parameters** 5181 5182| Name | Type | Mandatory | Description | 5183| ---------- | ------- | ---- | ---------------------------------- | 5184| type | [HighlightAlbumInfoType](#highlightalbuminfotype12) | Yes | Type of the album information to obtain.| 5185 5186**Error codes** 5187 5188For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 5189 5190| ID | Error Message | 5191| :------- | :-------------------------------- | 5192| 201 | Permission denied. | 5193| 202 | Called by non-system application. | 5194| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5195| 14000011 | Internal system error. | 5196 5197**Example** 5198 5199```ts 5200import { dataSharePredicates } from '@kit.ArkData'; 5201 5202async function example() { 5203 try { 5204 console.info('getHighlightAlbumInfoDemo') 5205 let fetchOptions: photoAccessHelper.FetchOptions = { 5206 fetchColumns: [], 5207 predicates: new dataSharePredicates.DataSharePredicates() 5208 } 5209 let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await photoAccessHelper.getAlbums( 5210 photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.HIGHLIGHT, fetchOption); 5211 let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject(); 5212 if (album != undefined) { 5213 let highlightAlbum: photoAccessHelper.HighlightAlbum = new photoAccessHelper.HighlightAlbum(album); 5214 let coverInfo: string = await highlightAlbum.getHighlightAlbumInfo( 5215 photoAccessHelper.HighlightAlbumInfoType.COVER_INFO); 5216 console.info('get cover info result: ' + JSON.stringify(coverInfo)); 5217 } 5218 5219 albumFetchResult.close(); 5220 } catch (err) { 5221 console.error(`getHighlightAlbumInfoDemofailed with error: ${err.code}, ${err.message}`); 5222 } 5223} 5224``` 5225 5226### getHighlightResource<sup>12+</sup> 5227 5228getHighlightResource(resourceUri: string): Promise<ArrayBuffer> 5229 5230Obtains the ArrayBuffer for caching the specified asset. 5231 5232**System API**: This is a system API. 5233 5234**Required permissions**: ohos.permission.READ\_IMAGEVIDEO 5235 5236**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5237 5238**Parameters** 5239 5240| Name | Type | Mandatory | Description | 5241| ---------- | ------- | ---- | ---------------------------------- | 5242| resourceUri | string | Yes | URI of the asset to cache.| 5243 5244**Error codes** 5245 5246For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 5247 5248| ID | Error Message | 5249| :------- | :-------------------------------- | 5250| 201 | Permission denied. | 5251| 202 | Called by non-system application. | 5252| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5253| 14000011 | Internal system error. | 5254 5255**Example** 5256 5257```ts 5258import { dataSharePredicates } from '@kit.ArkData'; 5259 5260async function example() { 5261 try { 5262 console.info('getHighlightResourceDemo') 5263 let fetchOptions: photoAccessHelper.FetchOptions = { 5264 fetchColumns: [], 5265 predicates: new dataSharePredicates.DataSharePredicates() 5266 } 5267 let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await photoAccessHelper.getAlbums( 5268 photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.HIGHLIGHT, fetchOption); 5269 let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject(); 5270 if (album != undefined) { 5271 let highlightAlbum: photoAccessHelper.HighlightAlbum = new photoAccessHelper.HighlightAlbum(album); 5272 let uri: string = 'file://media/highlight/cover/10/1_1/background.png?oper=highlight' 5273 let arrayBuffer: ArrayBuffer = await highlightAlbum.getHighlightResource(uri); 5274 } 5275 albumFetchResult.close(); 5276 } catch (err) { 5277 console.error(`getHighlightResourceDemofailed with error: ${err.code}, ${err.message}`); 5278 } 5279} 5280``` 5281 5282### setHighlightUserActionData<sup>12+</sup> 5283 5284setHighlightUserActionData(type: HighlightUserActionType, actionData: number): Promise<void> 5285 5286Sets the user behavior data for the **Highlights** album. 5287 5288**System API**: This is a system API. 5289 5290**Required permissions**: ohos.permission.WRITE\_IMAGEVIDEO 5291 5292**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5293 5294**Parameters** 5295 5296| Name | Type | Mandatory | Description | 5297| ---------- | ------- | ---- | ---------------------------------- | 5298| type | [HighlightUserActionType](#highlightuseractiontype12) | Yes | Type of the user behavior data to set.| 5299| actionData | number | Yes | Behavior data.| 5300 5301**Error codes** 5302 5303For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 5304 5305| ID | Error Message | 5306| :------- | :-------------------------------- | 5307| 201 | Permission denied. | 5308| 202 | Called by non-system application. | 5309| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5310| 14000011 | Internal system error. | 5311 5312**Example** 5313 5314```ts 5315import { dataSharePredicates } from '@kit.ArkData'; 5316 5317async function example() { 5318 try { 5319 console.info('setHighlightUserActionDataDemo') 5320 let fetchOptions: photoAccessHelper.FetchOptions = { 5321 fetchColumns: [], 5322 predicates: new dataSharePredicates.DataSharePredicates() 5323 } 5324 let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await photoAccessHelper.getAlbums( 5325 photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.HIGHLIGHT, fetchOption); 5326 let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject(); 5327 if (album != undefined) { 5328 let highlightAlbum: photoAccessHelper.HighlightAlbum = new photoAccessHelper.HighlightAlbum(album); 5329 highlightAlbum.setHighlightUserActionData(photoAccessHelper.HighlightUserActionType.INSERTED_PIC_COUNT, 1); 5330 } 5331 albumFetchResult.close(); 5332 } catch (err) { 5333 console.error(`setHighlightUserActionDataDemofailed with error: ${err.code}, ${err.message}`); 5334 } 5335} 5336``` 5337 5338## CloudEnhancement<sup>13+</sup> 5339 5340Provides APIs for cloud enhancement management, including managing the tasks of generating AI-powered cloud enhancement photos and obtaining the association between the original photos and AI cloud enhancement photos. 5341 5342**System API**: This is a system API. 5343 5344**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5345 5346### getCloudEnhancementInstance<sup>13+</sup> 5347 5348static getCloudEnhancementInstance(context: Context): CloudEnhancement 5349 5350Obtains a cloud enhancement instance. 5351 5352**System API**: This is a system API. 5353 5354**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5355 5356**Parameters** 5357 5358| Name | Type | Mandatory| Description | 5359| -------- | ------------------------- | ---- | ---------- | 5360| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes | Context of the ability instance.| 5361 5362**Error codes** 5363 5364For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 5365 5366| ID| Error Message| 5367| -------- | ---------------------------------------- | 5368| 202 | Called by non-system application. | 5369| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5370| 14000011 | Internal system error. | 5371 5372**Example** 5373 5374```ts 5375import { dataSharePredicates } from '@kit.ArkData'; 5376 5377async function example() { 5378 console.info('getCloudEnhancementInstanceDemo'); 5379 let photoPredicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 5380 let photoFetchOptions: photoAccessHelper.FetchOptions = { 5381 fetchColumns: [], 5382 predicates: photoPredicates 5383 }; 5384 let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context); 5385 try { 5386 let fetchResult = await phAccessHelper.getAssets(photoFetchOptions); 5387 let asset = await fetchResult.getLastObject(); 5388 let cloudEnhancementInstance: photoAccessHelper.CloudEnhancement 5389 = photoAccessHelper.CloudEnhancement.getCloudEnhancementInstance(context); 5390 let hasCloudWatermark = true; 5391 await cloudEnhancementInstance.submitCloudEnhancementTasks([asset], hasCloudWatermark); 5392 } catch (err) { 5393 console.error(`getCloudEnhancementInstanceDemo failed with error: ${err.code}, ${err.message}`); 5394 } 5395} 5396``` 5397 5398### submitCloudEnhancementTasks<sup>13+</sup> 5399 5400submitCloudEnhancementTasks(photoAssets: Array<PhotoAsset>, hasCloudWatermark: boolean): Promise<void> 5401 5402Submits cloud enhancement tasks. 5403 5404**System API**: This is a system API. 5405 5406**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5407 5408**Parameters** 5409 5410| Name | Type | Mandatory| Description | 5411| -------- | ------------------------- | ---- | ---------- | 5412| photoAssets | Array<[PhotoAsset](#photoasset)> | Yes | [PhotoAsset](#photoasset) to enhance.| 5413| hasCloudWatermark | boolean | Yes | Whether to add a cloud enhancement watermark to the enhanced images.| 5414 5415**Error codes** 5416 5417For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 5418 5419| ID| Error Message| 5420| -------- | ---------------------------------------- | 5421| 201 | Permission denied. | 5422| 202 | Called by non-system application. | 5423| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5424| 14000011 | Internal system error. | 5425 5426**Example** 5427 5428```ts 5429import { dataSharePredicates } from '@kit.ArkData'; 5430 5431async function example() { 5432 console.info('submitCloudEnhancementTasksDemo'); 5433 let photoPredicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 5434 let photoFetchOptions: photoAccessHelper.FetchOptions = { 5435 fetchColumns: [], 5436 predicates: photoPredicates 5437 }; 5438 let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context); 5439 try { 5440 let fetchResult = await phAccessHelper.getAssets(photoFetchOptions); 5441 let asset = await fetchResult.getLastObject(); 5442 let cloudEnhancementInstance: photoAccessHelper.CloudEnhancement 5443 = photoAccessHelper.CloudEnhancement.getCloudEnhancementInstance(context); 5444 let hasCloudWatermark = true; 5445 await cloudEnhancementInstance.submitCloudEnhancementTasks([asset], hasCloudWatermark); 5446 } catch (err) { 5447 console.error(`submitCloudEnhancementTasksDemo failed with error: ${err.code}, ${err.message}`); 5448 } 5449} 5450``` 5451 5452### prioritizeCloudEnhancementTask<sup>13+</sup> 5453 5454prioritizeCloudEnhancementTask(photoAsset: PhotoAsset): Promise<void> 5455 5456Prioritizes a cloud enhancement task. 5457 5458**System API**: This is a system API. 5459 5460**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5461 5462**Parameters** 5463 5464| Name | Type | Mandatory| Description | 5465| -------- | ------------------------- | ---- | ---------- | 5466| photoAsset | [PhotoAsset](#photoasset) | Yes | [PhotoAsset](#photoasset) whose cloud enhancement priority needs to be escalated.| 5467 5468**Error codes** 5469 5470For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 5471 5472| ID| Error Message| 5473| -------- | ---------------------------------------- | 5474| 201 | Permission denied. | 5475| 202 | Called by non-system application. | 5476| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5477| 14000011 | Internal system error. | 5478 5479**Example** 5480 5481```ts 5482import { dataSharePredicates } from '@kit.ArkData'; 5483 5484async function example() { 5485 console.info('prioritizeCloudEnhancementTaskDemo'); 5486 let photoPredicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 5487 // Obtain the cloud enhancement tasks in progress. 5488 photoPredicates.equalTo(photoAccessHelper.PhotoKeys.CE_AVAILABLE, 2); 5489 let photoFetchOptions: photoAccessHelper.FetchOptions = { 5490 fetchColumns: [], 5491 predicates: photoPredicates 5492 }; 5493 let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context); 5494 try { 5495 let fetchResult = await phAccessHelper.getAssets(photoFetchOptions); 5496 let asset = await fetchResult.getLastObject(); 5497 let cloudEnhancementInstance: photoAccessHelper.CloudEnhancement 5498 = photoAccessHelper.CloudEnhancement.getCloudEnhancementInstance(context); 5499 let hasCloudWatermark = true; 5500 await cloudEnhancementInstance.prioritizeCloudEnhancementTask(asset); 5501 } catch (err) { 5502 console.error(`prioritizeCloudEnhancementTaskDemo failed with error: ${err.code}, ${err.message}`); 5503 } 5504} 5505``` 5506 5507### cancelCloudEnhancementTasks<sup>13+</sup> 5508 5509cancelCloudEnhancementTasks(photoAssets: Array<PhotoAsset>): Promise<void> 5510 5511Cancels cloud enhancement tasks. 5512 5513**System API**: This is a system API. 5514 5515**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5516 5517**Parameters** 5518 5519| Name | Type | Mandatory| Description | 5520| -------- | ------------------------- | ---- | ---------- | 5521| photoAssets | Array<[PhotoAsset](#photoasset)> | Yes | Array of [PhotoAssets](#photoasset) whose cloud enhancement tasks are to be canceled.| 5522 5523**Error codes** 5524 5525For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 5526 5527| ID| Error Message| 5528| -------- | ---------------------------------------- | 5529| 201 | Permission denied. | 5530| 202 | Called by non-system application. | 5531| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5532| 14000011 | Internal system error. | 5533 5534**Example** 5535 5536```ts 5537import { dataSharePredicates } from '@kit.ArkData'; 5538 5539async function example() { 5540 console.info('cancelCloudEnhancementTasksDemo'); 5541 let photoPredicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 5542 // Obtain the cloud enhancement tasks in progress. 5543 photoPredicates.equalTo(photoAccessHelper.PhotoKeys.CE_AVAILABLE, 2); 5544 let photoFetchOptions: photoAccessHelper.FetchOptions = { 5545 fetchColumns: [], 5546 predicates: photoPredicates 5547 }; 5548 let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context); 5549 try { 5550 let fetchResult = await phAccessHelper.getAssets(photoFetchOptions); 5551 let asset = await fetchResult.getLastObject(); 5552 let cloudEnhancementInstance: photoAccessHelper.CloudEnhancement 5553 = photoAccessHelper.CloudEnhancement.getCloudEnhancementInstance(context); 5554 await cloudEnhancementInstance.cancelCloudEnhancementTasks([asset]); 5555 } catch (err) { 5556 console.error(`cancelCloudEnhancementTasksDemo failed with error: ${err.code}, ${err.message}`); 5557 } 5558} 5559``` 5560 5561### cancelAllCloudEnhancementTasks<sup>13+</sup> 5562 5563cancelAllCloudEnhancementTasks(): Promise<void> 5564 5565Cancels all cloud enhancement tasks. 5566 5567**System API**: This is a system API. 5568 5569**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5570 5571**Error codes** 5572 5573For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 5574 5575| ID| Error Message| 5576| -------- | ---------------------------------------- | 5577| 201 | Permission denied. | 5578| 202 | Called by non-system application. | 5579| 14000011 | Internal system error. | 5580 5581**Example** 5582 5583```ts 5584import { dataSharePredicates } from '@kit.ArkData'; 5585 5586async function example() { 5587 console.info('cancelAllCloudEnhancementTasksDemo'); 5588 try { 5589 let cloudEnhancementInstance: photoAccessHelper.CloudEnhancement 5590 = photoAccessHelper.CloudEnhancement.getCloudEnhancementInstance(context); 5591 await cloudEnhancementInstance.cancelCloudEnhancementTasks(); 5592 } catch (err) { 5593 console.error(`cancelAllCloudEnhancementTasksDemo failed with error: ${err.code}, ${err.message}`); 5594 } 5595} 5596``` 5597 5598### queryCloudEnhancementTaskState<sup>13+</sup> 5599 5600queryCloudEnhancementTaskState(photoAsset: PhotoAsset): Promise<CloudEnhancementTaskState> 5601 5602Queries information about a cloud enhancement task. 5603 5604**System API**: This is a system API. 5605 5606**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5607 5608**Parameters** 5609 5610| Name | Type | Mandatory| Description | 5611| -------- | ------------------------- | ---- | ---------- | 5612| photoAsset | [PhotoAsset](#photoasset) | Yes | [PhotoAsset](#photoasset) whose cloud enhancement task information is to be queried.| 5613 5614**Error codes** 5615 5616For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 5617 5618| ID| Error Message| 5619| -------- | ---------------------------------------- | 5620| 201 | Permission denied. | 5621| 202 | Called by non-system application. | 5622| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5623| 14000011 | Internal system error. | 5624 5625**Example** 5626 5627```ts 5628import { dataSharePredicates } from '@kit.ArkData'; 5629 5630async function example() { 5631 console.info('queryCloudEnhancementTaskStateDemo'); 5632 let photoPredicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 5633 // Obtain the cloud enhancement tasks in progress. 5634 photoPredicates.equalTo(photoAccessHelper.PhotoKeys.CE_AVAILABLE, 2); 5635 let photoFetchOptions: photoAccessHelper.FetchOptions = { 5636 fetchColumns: [], 5637 predicates: photoPredicates 5638 }; 5639 let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context); 5640 try { 5641 let fetchResult = await phAccessHelper.getAssets(photoFetchOptions); 5642 let asset = await fetchResult.getLastObject(); 5643 let cloudEnhancementInstance: photoAccessHelper.CloudEnhancement 5644 = photoAccessHelper.CloudEnhancement.getCloudEnhancementInstance(context); 5645 const cloudEnhancementTaskState: photoAccessHelper.CloudEnhancementTaskState 5646 = await cloudEnhancementInstance.queryCloudEnhancementTaskState(asset); 5647 let taskStage = cloudEnhancementTaskState.taskStage; 5648 if (taskStage == photoAccessHelper.CloudEnhancementTaskStage.TASK_STAGE_EXCEPTION) { 5649 console.log("task has exception"); 5650 } else if (taskStage == photoAccessHelper.CloudEnhancementTaskStage.TASK_STAGE_PREPARING) { 5651 console.log("task is preparing"); 5652 } else if (taskStage == photoAccessHelper.CloudEnhancementTaskStage.TASK_STAGE_UPLOADING) { 5653 let transferredFileSize = cloudEnhancementTaskState.transferredFileSize; 5654 let totalFileSize = cloudEnhancementTaskState.totalFileSize; 5655 let message = `task is uploading, transferredFileSize: ${transferredFileSize}, totalFileSize: ${totalFileSize}`; 5656 console.log(message); 5657 } else if (taskStage == photoAccessHelper.CloudEnhancementTaskStage.TASK_STAGE_EXECUTING) { 5658 let expectedDuration = cloudEnhancementTaskState.expectedDuration; 5659 let message = `task is executing, expectedDuration: ${expectedDuration}`; 5660 console.log(message); 5661 } else if (taskStage == photoAccessHelper.CloudEnhancementTaskStage.TASK_STAGE_DOWNLOADING) { 5662 let transferredFileSize = cloudEnhancementTaskState.transferredFileSize; 5663 let totalFileSize = cloudEnhancementTaskState.totalFileSize; 5664 let message = `task is downloading, transferredFileSize: ${transferredFileSize}, totalFileSize: ${totalFileSize}`; 5665 console.log(message); 5666 } else if (taskStage == photoAccessHelper.CloudEnhancementTaskStage.TASK_STAGE_FAILED) { 5667 let errCode = cloudEnhancementTaskState.statusCode; 5668 let message = `task is failed, errCode: ${errCode}`; 5669 console.log(message); 5670 } else if (taskStage == photoAccessHelper.CloudEnhancementTaskStage.TASK_STAGE_COMPLETED) { 5671 console.log("task is completed"); 5672 } 5673 } catch (err) { 5674 console.error(`queryCloudEnhancementTaskStateDemo failed with error: ${err.code}, ${err.message}`); 5675 } 5676} 5677``` 5678 5679### syncCloudEnhancementTaskStatus<sup>13+</sup> 5680 5681syncCloudEnhancementTaskStatus(): Promise<void> 5682 5683Synchronizes the cloud enhancement task status. 5684 5685**System API**: This is a system API. 5686 5687**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5688 5689**Error codes** 5690 5691For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 5692 5693| ID| Error Message| 5694| -------- | ---------------------------------------- | 5695| 201 | Permission denied. | 5696| 202 | Called by non-system application. | 5697| 14000011 | Internal system error. | 5698 5699**Example** 5700 5701```ts 5702import { dataSharePredicates } from '@kit.ArkData'; 5703 5704async function example() { 5705 console.info('syncCloudEnhancementTaskStatusDemo'); 5706 try { 5707 let cloudEnhancementInstance: photoAccessHelper.CloudEnhancement 5708 = photoAccessHelper.CloudEnhancement.getCloudEnhancementInstance(context); 5709 await cloudEnhancementInstance.syncCloudEnhancementTaskStatus(); 5710 } catch (err) { 5711 console.error(`syncCloudEnhancementTaskStatusDemo failed with error: ${err.code}, ${err.message}`); 5712 } 5713} 5714``` 5715 5716### getCloudEnhancementPair<sup>13+</sup> 5717 5718getCloudEnhancementPair(asset: PhotoAsset): Promise<PhotoAsset> 5719 5720Obtains the photo after cloud enhancement. 5721 5722**System API**: This is a system API. 5723 5724**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5725 5726**Parameters** 5727 5728| Name | Type | Mandatory| Description | 5729| -------- | ------------------------- | ---- | ---------- | 5730| photoAsset | [PhotoAsset](#photoasset) | Yes | [PhotoAsset](#photoasset) whose cloud enhancement photo is to be obtained.| 5731 5732**Error codes** 5733 5734For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 5735 5736| ID| Error Message| 5737| -------- | ---------------------------------------- | 5738| 201 | Permission denied. | 5739| 202 | Called by non-system application. | 5740| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5741| 14000011 | Internal system error. | 5742 5743**Example** 5744 5745```ts 5746import { dataSharePredicates } from '@kit.ArkData'; 5747 5748async function example() { 5749 console.info('getCloudEnhancementPairDemo'); 5750 let photoPredicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 5751 // Query the completed cloud enhancement tasks. 5752 photoPredicates.equalTo(photoAccessHelper.PhotoKeys.CE_AVAILABLE, 5); 5753 let photoFetchOptions: photoAccessHelper.FetchOptions = { 5754 fetchColumns: [], 5755 predicates: photoPredicates 5756 }; 5757 let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context); 5758 try { 5759 let fetchResult = await phAccessHelper.getAssets(photoFetchOptions); 5760 let asset = await fetchResult.getLastObject(); 5761 let cloudEnhancementInstance: photoAccessHelper.CloudEnhancement 5762 = photoAccessHelper.CloudEnhancement.getCloudEnhancementInstance(context); 5763 let photoAsset: photoAccessHelper.PhotoAsset 5764 = await cloudEnhancementInstance.getCloudEnhancementPair(asset); 5765 } catch (err) { 5766 console.error(`getCloudEnhancementPairDemo failed with error: ${err.code}, ${err.message}`); 5767 } 5768} 5769``` 5770 5771### setVideoEnhancementAttr<sup>13+</sup> 5772 5773setVideoEnhancementAttr(videoEnhancementType: VideoEnhancementType, photoId: string): Promise<void> 5774 5775Sets the attributes for deferred video enhancement. 5776 5777**System API**: This is a system API. 5778 5779**Required permissions**: ohos.permission.WRITE\_IMAGEVIDEO 5780 5781**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5782 5783**Parameters** 5784 5785| Name | Type | Mandatory | Description | 5786| ---------- | ------- | ---- | ---------------------------------- | 5787| videoEnhancementType | [VideoEnhancementType](#videoenhancementtype13) | Yes | Type of video enhancement.| 5788| photoId | string | Yes | Photo ID of the image.| 5789 5790**Error codes** 5791 5792For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 5793 5794| ID | Error Message | 5795| :------- | :-------------------------------- | 5796| 202 | Called by non-system application. | 5797| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5798| 14000011 | Internal system error. | 5799| 14000016 | Operation Not Support. | 5800 5801**Example** 5802 5803```ts 5804async function example(asset: photoAccessHelper.PhotoAsset) { 5805 try { 5806 let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset); 5807 let photoId = "202410011800"; 5808 assetChangeRequest.setVideoEnhancementAttr(photoAccessHelper.VideoEnhancementType.QUALITY_ENHANCEMENT_LOCAL, photoId); 5809 await phAccessHelper.applyChanges(assetChangeRequest); 5810 } catch (err) { 5811 console.error(`setVideoEnhancementAttr fail with error: ${err.code}, ${err.message}`); 5812 } 5813} 5814``` 5815 5816### getFaceId<sup>13+</sup> 5817 5818getFaceId(): Promise\<string> 5819 5820Obtains the face identifier on the cover of a portrait album or group photo album. 5821 5822**System API**: This is a system API. 5823 5824**Required permissions**: ohos.permission.READ\_IMAGEVIDEO 5825 5826**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5827 5828**Return value** 5829 5830| Type | Description | 5831| :------------------ | :---------------------------------- | 5832| Promise<string> | Promise used to return **tag_id** of the portrait album, **group_tag** of the group photo album, or an empty string if no face identifier is found.| 5833 5834**Error codes** 5835 5836For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 5837 5838| ID| Error Message | 5839| :------- | :----------------------------------------------------------- | 5840| 201 | Permission denied. | 5841| 202 | Called by non-system application. | 5842| 14000011 | Internal system error | 5843 5844**Example** 5845 5846```ts 5847import { dataSharePredicates } from '@kit.ArkData'; 5848 5849async function example() { 5850 try { 5851 console.info('getFaceIdDemo'); 5852 let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); 5853 predicates.equalTo("user_display_level", 1); 5854 let fetchOptions: photoAccessHelper.FetchOptions = { 5855 fetchColumns: [], 5856 predicates: predicates 5857 }; 5858 let fetchResult = 5859 await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.PORTRAIT, 5860 fetchOptions); 5861 let album = await fetchResult?.getFirstObject(); 5862 let faceId = await album?.getFaceId(); 5863 console.info(`getFaceId successfully, faceId: ${faceId}`); 5864 fetchResult.close(); 5865 } catch (err) { 5866 console.error(`getFaceId failed with err: ${err.code}, ${err.message}`); 5867 } 5868} 5869``` 5870 5871## CloudMediaAssetManager<sup>14+</sup> 5872 5873A class used for cloud media asset management. It is used to manage download tasks for media assets stored in the cloud and delete local data and files pertaining to these cloud-based assets. 5874 5875**System API**: This is a system API. 5876 5877**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5878 5879### getCloudMediaAssetManagerInstance<sup>14+</sup> 5880 5881static getCloudMediaAssetManagerInstance(context: Context): CloudMediaAssetManager 5882 5883Obtains a CloudMediaAssetManager instance. 5884 5885**System API**: This is a system API. 5886 5887**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5888 5889**Parameters** 5890 5891| Name | Type | Mandatory| Description | 5892| -------- | ------------------------- | ---- | ---------- | 5893| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes | Context of the ability instance.| 5894 5895**Return value** 5896 5897| Type | Description | 5898| --------------------------------------- | ----------------- | 5899| [CloudMediaAssetManager](#cloudmediaassetmanager14) | CloudMediaAssetManager instance.| 5900 5901**Error codes** 5902 5903For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 5904 5905| ID| Error Message| 5906| -------- | ---------------------------------------- | 5907| 202 | Called by non-system application. | 5908| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5909| 14000011 | Internal system error. It is recommended to retry and check the logs. Possible causes: 1. Database corrupted; 2. The file system is abnormal; 3. The IPC request timed out. | 5910 5911**Example** 5912 5913```ts 5914import photoAccessHelper from '@ohos.file.photoAccessHelper' 5915const context = getContext(this); 5916async function example() { 5917 console.info('getCloudMediaAssetManagerInstanceDemo'); 5918 try { 5919 let cloudMediaAssetManagerInstance: photoAccessHelper.CloudMediaAssetManager 5920 = photoAccessHelper.CloudMediaAssetManager.getCloudMediaAssetManagerInstance(context); 5921 await cloudMediaAssetManagerInstance.pauseDownloadCloudMedia(); 5922 } catch (err) { 5923 console.error(`getCloudMediaAssetManagerInstanceDemo failed with error: ${err.code}, ${err.message}`); 5924 } 5925} 5926``` 5927 5928### startDownloadCloudMedia<sup>14+</sup> 5929 5930startDownloadCloudMedia(downloadType: CloudMediaDownloadType): Promise<void> 5931 5932Starts or resumes a task to download cloud media assets. 5933 5934**System API**: This is a system API. 5935 5936**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5937 5938**Parameters** 5939 5940| Name | Type | Mandatory| Description | 5941| -------- | ------------------------- | ---- | ---------- | 5942| downloadType | [CloudMediaDownloadType](#cloudmediadownloadtype14) | Yes | Type of the download task.| 5943 5944**Return value** 5945 5946| Type | Description | 5947| --------------------------------------- | ----------------- | 5948| Promise<void>| Promise that returns no value.| 5949 5950**Error codes** 5951 5952For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 5953 5954| ID| Error Message| 5955| -------- | ---------------------------------------- | 5956| 201 | Permission denied. | 5957| 202 | Called by non-system application. | 5958| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 5959| 14000011 | Internal system error. It is recommended to retry and check the logs. Possible causes: 1. Database corrupted; 2. The file system is abnormal; 3. The IPC request timed out. | 5960 5961**Example** 5962 5963```ts 5964import photoAccessHelper from '@ohos.file.photoAccessHelper' 5965const context = getContext(this); 5966async function example() { 5967 console.info('startDownloadCloudMediaDemo'); 5968 try { 5969 let cloudMediaAssetManagerInstance: photoAccessHelper.CloudMediaAssetManager 5970 = photoAccessHelper.CloudMediaAssetManager.getCloudMediaAssetManagerInstance(context); 5971 await cloudMediaAssetManagerInstance.startDownloadCloudMedia(photoAccessHelper.CloudMediaDownloadType.DOWNLOAD_FORCE); 5972 } catch (err) { 5973 console.error(`startDownloadCloudMediaDemo failed with error: ${err.code}, ${err.message}`); 5974 } 5975} 5976``` 5977 5978### pauseDownloadCloudMedia<sup>14+</sup> 5979 5980pauseDownloadCloudMedia(): Promise<void> 5981 5982Suspends a task that downloads cloud media assets. 5983 5984**System API**: This is a system API. 5985 5986**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 5987 5988**Return value** 5989 5990| Type | Description | 5991| --------------------------------------- | ----------------- | 5992| Promise<void>| Promise that returns no value.| 5993 5994**Error codes** 5995 5996For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 5997 5998| ID| Error Message| 5999| -------- | ---------------------------------------- | 6000| 201 | Permission denied. | 6001| 202 | Called by non-system application. | 6002| 14000011 | Internal system error. It is recommended to retry and check the logs. Possible causes: 1. Database corrupted; 2. The file system is abnormal; 3. The IPC request timed out. | 6003 6004**Example** 6005 6006```ts 6007import photoAccessHelper from '@ohos.file.photoAccessHelper' 6008const context = getContext(this); 6009async function example() { 6010 console.info('pauseDownloadCloudMediaDemo'); 6011 try { 6012 let cloudMediaAssetManagerInstance: photoAccessHelper.CloudMediaAssetManager 6013 = photoAccessHelper.CloudMediaAssetManager.getCloudMediaAssetManagerInstance(context); 6014 await cloudMediaAssetManagerInstance.pauseDownloadCloudMedia(); 6015 } catch (err) { 6016 console.error(`pauseDownloadCloudMediaDemo failed with error: ${err.code}, ${err.message}`); 6017 } 6018} 6019``` 6020 6021### cancelDownloadCloudMedia<sup>14+</sup> 6022 6023cancelDownloadCloudMedia(): Promise<void> 6024 6025Cancels a task that downloads cloud media assets. 6026 6027**System API**: This is a system API. 6028 6029**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6030 6031**Return value** 6032 6033| Type | Description | 6034| --------------------------------------- | ----------------- | 6035| Promise<void>| Promise that returns no value.| 6036 6037**Error codes** 6038 6039For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 6040 6041| ID| Error Message| 6042| -------- | ---------------------------------------- | 6043| 201 | Permission denied. | 6044| 202 | Called by non-system application. | 6045| 14000011 | Internal system error. It is recommended to retry and check the logs. Possible causes: 1. Database corrupted; 2. The file system is abnormal; 3. The IPC request timed out. | 6046 6047**Example** 6048 6049```ts 6050import photoAccessHelper from '@ohos.file.photoAccessHelper' 6051const context = getContext(this); 6052async function example() { 6053 console.info('cancelDownloadCloudMediaDemo'); 6054 try { 6055 let cloudMediaAssetManagerInstance: photoAccessHelper.CloudMediaAssetManager 6056 = photoAccessHelper.CloudMediaAssetManager.getCloudMediaAssetManagerInstance(context); 6057 await cloudMediaAssetManagerInstance.cancelDownloadCloudMedia(); 6058 } catch (err) { 6059 console.error(`cancelDownloadCloudMediaDemo failed with error: ${err.code}, ${err.message}`); 6060 } 6061} 6062``` 6063 6064### retainCloudMediaAsset<sup>14+</sup> 6065 6066retainCloudMediaAsset(retainType: CloudMediaRetainType): Promise<void> 6067 6068Deletes local metadata and files of cloud media assets. 6069 6070**System API**: This is a system API. 6071 6072**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6073 6074**Parameters** 6075 6076| Name | Type | Mandatory| Description | 6077| -------- | ------------------------- | ---- | ---------- | 6078| retainType | [CloudMediaRetainType](#cloudmediaretaintype14) | Yes | Mode for deleting cloud media assets.| 6079 6080**Return value** 6081 6082| Type | Description | 6083| --------------------------------------- | ----------------- | 6084| Promise<void>| Promise that returns no value.| 6085 6086**Error codes** 6087 6088For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 6089 6090| ID| Error Message| 6091| -------- | ---------------------------------------- | 6092| 201 | Permission denied. | 6093| 202 | Called by non-system application. | 6094| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 6095| 14000011 | Internal system error. It is recommended to retry and check the logs. Possible causes: 1. Database corrupted; 2. The file system is abnormal; 3. The IPC request timed out. | 6096 6097**Example** 6098 6099```ts 6100import photoAccessHelper from '@ohos.file.photoAccessHelper' 6101const context = getContext(this); 6102async function example() { 6103 console.info('retainCloudMediaAssetDemo'); 6104 try { 6105 let cloudMediaAssetManagerInstance: photoAccessHelper.CloudMediaAssetManager 6106 = photoAccessHelper.CloudMediaAssetManager.getCloudMediaAssetManagerInstance(context); 6107 await cloudMediaAssetManagerInstance.retainCloudMediaAsset(photoAccessHelper.CloudMediaRetainType.RETAIN_FORCE); 6108 } catch (err) { 6109 console.error(`retainCloudMediaAssetDemo failed with error: ${err.code}, ${err.message}`); 6110 } 6111} 6112``` 6113 6114### getCloudMediaAssetStatus<sup>14+</sup> 6115 6116getCloudMediaAssetStatus(): Promise<CloudMediaAssetStatus> 6117 6118Obtains the status of a task that downloads cloud media assets. 6119 6120**System API**: This is a system API. 6121 6122**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6123 6124**Return value** 6125 6126| Type | Description | 6127| --------------------------------------- | ----------------- | 6128|Promise<[CloudMediaAssetStatus](#cloudmediaassetstatus14)> | Promise used to return the task status.| 6129 6130**Error codes** 6131 6132For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md). 6133 6134| ID| Error Message| 6135| -------- | ---------------------------------------- | 6136| 201 | Permission denied. | 6137| 202 | Called by non-system application. | 6138| 14000011 | Internal system error. It is recommended to retry and check the logs. Possible causes: 1. Database corrupted; 2. The file system is abnormal; 3. The IPC request timed out. | 6139 6140**Example** 6141 6142```ts 6143import photoAccessHelper from '@ohos.file.photoAccessHelper' 6144const context = getContext(this); 6145async function example() { 6146 console.info('getCloudMediaAssetStatusDemo'); 6147 try { 6148 let cloudMediaAssetManagerInstance: photoAccessHelper.CloudMediaAssetManager 6149 = photoAccessHelper.CloudMediaAssetManager.getCloudMediaAssetManagerInstance(context); 6150 const cloudMediaAssetStatus: photoAccessHelper.CloudMediaAssetStatus = await cloudMediaAssetManagerInstance.getCloudMediaAssetStatus(); 6151 let taskStatus = cloudMediaAssetStatus.taskStatus; 6152 let taskInfo = cloudMediaAssetStatus.taskInfo; 6153 let errorCode = cloudMediaAssetStatus.errorCode; 6154 let message = `taskStatus: ${taskStatus}, taskInfo: ${taskInfo}, errorCode: ${errorCode}`; 6155 console.log(message); 6156 } catch (err) { 6157 console.error(`getCloudMediaAssetStatusDemo failed with error: ${err.code}, ${err.message}`); 6158 } 6159} 6160``` 6161 6162## PhotoSubtype 6163 6164Enumerates the [PhotoAsset](#photoasset) types. 6165 6166**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6167 6168| Name | Value| Description| 6169| ----- | ---- | ---- | 6170| SCREENSHOT | 1 | Screenshot and screen recording file. <br>**System API**: This is a system API.| 6171 6172## PositionType 6173 6174Enumerates the file locations. 6175 6176**System API**: This is a system API. 6177 6178**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6179 6180| Name | Value| Description| 6181| ----- | ---- | ---- | 6182| LOCAL | 1 << 0 | Stored only on a local device.| 6183| CLOUD | 1 << 1 | Stored only on the cloud.| 6184 6185## AlbumType 6186 6187Enumerates the album types. 6188 6189**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6190 6191| Name | Value | Description | 6192| ------------------- | ---- | ------------------------- | 6193| SMART<sup>11+</sup> | 4096 | Smart analysis album. <br>**System API**: This is a system API.| 6194 6195## AlbumSubtype 6196 6197Enumerate the album subtypes. 6198 6199**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6200 6201| Name | Value | Description | 6202| --------------------------------- | ---------- | ------------------------------- | 6203| HIDDEN | 1027 | Hidden album. <br>**System API**: This is a system API. | 6204| TRASH | 1028 | Trash. <br>**System API**: This is a system API. | 6205| SCREENSHOT | 1029 | Album for screenshots and screen recording files. <br>**System API**: This is a system API. | 6206| CAMERA | 1030 | Album for photos and videos taken by the camera. <br>**System API**: This is a system API.| 6207| SOURCE\_GENERIC<sup>11+</sup> | 2049 | Source album. <br>**System API**: This is a system API. | 6208| CLASSIFY<sup>11+</sup> | 4097 | Classified album. <br>**System API**: This is a system API. | 6209| GEOGRAPHY\_LOCATION<sup>11+</sup> | 4099 | Geographic location album. <br>**System API**: This is a system API. | 6210| GEOGRAPHY\_CITY<sup>11+</sup> | 4100 | City album. <br>**System API**: This is a system API. | 6211| SHOOTING\_MODE<sup>11+</sup> | 4101 | Shooting mode album. <br>**System API**: This is a system API. | 6212| PORTRAIT<sup>11+</sup> | 4102 | Portrait album. <br>**System API**: This is a system API. | 6213| GROUP_PHOTO<sup>13+</sup> | 4103 | Group photo album. <br>**System API**: This is a system API. | 6214| HIGHLIGHT<sup>12+</sup> | 4104 | Highlights album. <br>**System API**: This is a system API. | 6215| HIGHLIGHT_SUGGESTIONS<sup>12+</sup> | 4105 | Highlights suggestion album. <br>**System API**: This is a system API. | 6216| CLOUD_ENHANCEMENT<sup>13+</sup> | 1032 | AI-powered cloud enhanced album. <br>**System API**: This is a system API. | 6217 6218## RequestPhotoType<sup>11+</sup> 6219 6220Enumerates the types of the operation for obtaining image or video thumbnails. 6221 6222**System API**: This is a system API. 6223 6224**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6225 6226| Name | Value| Description| 6227| ----- | ---- | ---- | 6228| REQUEST_ALL_THUMBNAILS | 0 | Obtain both the quick thumbnail and the quality thumbnail.| 6229| REQUEST_FAST_THUMBNAIL | 1 | Obtain only the quick thumbnail.| 6230| REQUEST_QUALITY_THUMBNAIL | 2 | Obtain only the quality thumbnail.| 6231 6232## PhotoKeys 6233 6234Defines the key information about an image or video file. 6235 6236**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6237 6238| Name | Value | Description | 6239| ------------- | ------------------- | ---------------------------------------------------------- | 6240| POSITION | 'position' | File location type. <br>**System API**: This is a system API. | 6241| DATE_TRASHED | 'date_trashed' | Date when the file was deleted. The value is the number of seconds elapsed since the Epoch time. <br>**System API**: This is a system API. | 6242| HIDDEN | 'hidden' | Whether the file is hidden. <br>**System API**: This is a system API. | 6243| CAMERA_SHOT_KEY | 'camera_shot_key' | Key for the Ultra Snapshot feature, which allows the camera to take photos or record videos with the screen off. (This parameter is available only for the system camera, and the key value is defined by the system camera.) <br>**System API**: This is a system API. | 6244| USER_COMMENT<sup>10+</sup> | 'user_comment' | User comment information. <br>**System API**: This is a system API. | 6245| DATE_YEAR<sup>11+</sup> | 'date_year' | Year when the file was created. <br>**System API**: This is a system API. | 6246| DATE_MONTH<sup>11+</sup> | 'date_month' | Month when the file was created. <br>**System API**: This is a system API. | 6247| DATE_DAY<sup>11+</sup> | 'date_day' | Date when the file was created. <br>**System API**: This is a system API. | 6248| PENDING<sup>11+</sup> | 'pending' | Pending state. <br>**System API**: This is a system API. | 6249| DATE_TRASHED_MS<sup>12+</sup> | 'date_trashed_ms' | Date when the file was deleted. The value is the number of milliseconds elapsed since the Epoch time. **System API**: This is a system API.<br>**NOTE**: The photos queried cannot be sorted based on this field.| 6250| MOVING_PHOTO_EFFECT_MODE<sup>12+</sup> | 'moving_photo_effect_mode' | Effect of the moving photo. <br>**System API**: This is a system API.| 6251| CE_AVAILABLE<sup>13+</sup> | 'ce_available' | Cloud enhancement identifier. <br>**System API**: This is a system API.| 6252| SUPPORTED_WATERMARK_TYPE<sup>14+</sup> | 'supported_watermark_type' | Editable watermark identifier. <br>**System API**: This is a system API.| 6253 6254## HiddenPhotosDisplayMode<sup>11+</sup> 6255 6256Enumerates the display modes of hidden files in the system. 6257 6258**System API**: This is a system API. 6259 6260**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6261 6262| Name | Value | Description | 6263| ------------- | ------------------- | ---------------------------------------------------------- | 6264| ASSETS_MODE | 0 | Display all hidden files in the system. | 6265| ALBUMS_MODE | 1 | Display hidden files by album (display all albums that contain hidden files in the system, excluding the preset hidden album and the albums in the trash). | 6266 6267## PhotoCreateOptions 6268 6269Options for creating an image or video asset. 6270 6271**System API**: This is a system API. 6272 6273**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6274 6275| Name | Type | Mandatory| Description | 6276| ---------------------- | ------------------- | ---- | ------------------------------------------------ | 6277| subtype | [PhotoSubtype](#photosubtype) | No | Subtype of the image or video. | 6278| cameraShotKey | string | No | Key for the Ultra Snapshot feature, which allows the camera to take photos or record videos with the screen off. (This parameter is available only for the system camera, and the key value is defined by the system camera.) | 6279 6280## RequestPhotoOptions<sup>11+</sup> 6281 6282Defines the options for obtaining the thumbnail of an image or video. 6283 6284**System API**: This is a system API. 6285 6286**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6287 6288| Name | Type | Mandatory| Description | 6289| ---------------------- | ------------------- | ---- | ------------------------------------------------ | 6290| size | [image.Size](../apis-image-kit/js-apis-image.md#size) | No | Size of the thumbnail to obtain. | 6291| requestPhotoType | [RequestPhotoType](#requestphototype11) | No | Operation to perform. | 6292 6293## RequestOptions<sup>11+</sup> 6294 6295Represents request options. 6296 6297**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6298 6299| Name | Type | Readable| Writable| Description | 6300| ---------------------- |---------------------------------| ---- |---- | ------------------------------------------------ | 6301| sourceMode | [SourceMode](#sourcemode11) | Yes | Yes | Type of the asset file requested, which can be the original file or edited file. <br>**System API**: This is a system API.| 6302 6303## PhotoProxy<sup>11+</sup> 6304 6305Photo proxy object, which is used by the camera application to write image data. 6306 6307**System API**: This is a system API. 6308 6309**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6310 6311## MediaChangeRequest<sup>11+</sup> 6312 6313Media change request, which is the parent class of the asset change request and album change request. 6314 6315> **NOTE**<br>The media change request takes effect only after [applyChanges](js-apis-photoAccessHelper.md#applychanges11) is called. 6316 6317**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6318 6319## FormInfo<sup>11+</sup> 6320 6321Defines the Gallery widget information. 6322 6323**System API**: This is a system API. 6324 6325**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6326 6327| Name | Type | Mandatory| Description | 6328| ---------------------- | ------------------- | ---- | ------------------------------------------------ | 6329|formId |string |Yes| Widget ID, which is provided when a widget is created in Gallery.| 6330|uri |string |Yes| URI of the image bound to the widget. When a widget is created, **uri** can be empty or the URI of an image. When a widget is removed, **uri** is not verified and can be empty. | 6331 6332## ResourceType<sup>11+</sup> 6333 6334Enumerates the types of the resources to write. 6335 6336**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6337 6338| Name | Value| Description| 6339| ----- | ---- | ---- | 6340| PHOTO_PROXY | 3 | Photo proxy. <br>**System API**: This is a system API.| 6341| PRIVATE_MOVING_PHOTO_RESOURCE<sup>13+</sup> | 4 | Private moving photo. <br>**System API**: This is a system API.| 6342 6343## DefaultChangeUri 6344 6345Enumerates the **DefaultChangeUri** subtypes. 6346 6347**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6348 6349| Name | Value | Description | 6350| ----------------- | ----------------------- | ------------------------------------------------------------ | 6351| DEFAULT_HIDDEN_ALBUM_URI<sup>11+</sup> | 'file://media/HiddenAlbum' | URI of an album in the hidden albums that are displayed by album, that is, the URI of an album with hidden files. Such albums do not include the preset hidden album and the albums in the trash. This URI is used to subscribe to the change notifications of the hidden albums displayed by album. <br>**System API**: This is a system API.| 6352 6353## SourceMode<sup>11+</sup> 6354 6355Enumerates the types of the file to read. 6356 6357**System API**: This is a system API. 6358 6359**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6360 6361| Name | Value| Description| 6362| ----- | ---- | ---- | 6363| ORIGINAL_MODE | 0 | Original file.| 6364| EDITED_MODE | 1 | Edited file.| 6365## AuthorizationMode<sup>12+</sup> 6366 6367Enumerates the authorization modes. 6368 6369**System API**: This is a system API. 6370 6371**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6372 6373| Name | Value| Description| 6374| ----- | ---- | ---- | 6375| SHORT_TIME_AUTHORIZATION| 0 | Temporary authorization.| 6376 6377## AnalysisType<sup>11+</sup> 6378 6379Enumerates the smart analysis types. 6380 6381**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6382 6383| Name | Value | Description | 6384| :---------------------------- | :- | :------- | 6385| ANALYSIS\_AESTHETICS\_SCORE | 0 | Aesthetics score. <br>**System API**: This is a system API. | 6386| ANALYSIS\_LABEL | 1 | Label. <br>**System API**: This is a system API. | 6387| ANALYSIS\_OCR | 2 | Optical character recognition (OCR) analysis. <br>**System API**: This is a system API. | 6388| ANALYSIS\_FACE | 3 | Facial detection analysis. <br>**System API**: This is a system API. | 6389| ANALYSIS\_OBJECT | 4 | Object detection analysis. <br>**System API**: This is a system API. | 6390| ANALYSIS\_RECOMMENDATION | 5 | Recommendation analysis. <br>**System API**: This is a system API. | 6391| ANALYSIS\_SEGMENTATION | 6 | Segmentation analysis. <br>**System API**: This is a system API. | 6392| ANALYSIS\_COMPOSITION | 7 | Aesthetic composition analysis. <br>**System API**: This is a system API. | 6393| ANALYSIS\_SALIENCY | 8 | Salience analysis. <br>**System API**: This is a system API. | 6394| ANALYSIS\_DETAIL\_ADDRESS | 9 | Detailed address analysis. <br>**System API**: This is a system API. | 6395| ANALYSIS\_HUMAN\_FACE\_TAG<sup>12+</sup> | 10 | Face clustering analysis. <br>**System API**: This is a system API. | 6396| ANALYSIS\_HEAD\_POSITION<sup>12+</sup> | 11 | Analysis of the position of a person's or pet's head. <br>**System API**: This is a system API. | 6397| ANALYSIS\_BONE\_POSE<sup>12+</sup> | 12 | Analysis of the position of skeletal elements (bones) in a human body. <br>**System API**: This is a system API. | 6398| ANALYSIS\_VIDEO\_LABEL<sup>12+</sup> | 13 | Video label analysis. <br>**System API**: This is a system API. | 6399 6400## HighlightAlbumInfoType<sup>12+</sup> 6401 6402Enumerates the types of the highlights album information. 6403 6404**System API**: This is a system API. 6405 6406**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6407 6408| Name | Value | Description | 6409| :------------ | :- | :------- | 6410| COVER\_INFO | 0 | Cover information. | 6411| PLAY\_INFO | 1 | Music information. | 6412 6413## HighlightUserActionType<sup>12+</sup> 6414 6415Enumerates the user behavior types of the highlights album. 6416 6417**System API**: This is a system API. 6418 6419**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6420 6421| Name | Value | Description | 6422| :---------------------------- | :- | :------- | 6423| INSERTED\_PIC\_COUNT | 0 | Number of inserted pictures. | 6424| REMOVED\_PIC\_COUNT | 1 | Number of removed pictures. | 6425| SHARED\_SCREENSHOT\_COUNT | 2 | Number of times that a full-length image in a highlights album is shared. | 6426| SHARED\_COVER\_COUNT | 3 | Number of times that a highlights cover is shared. | 6427| RENAMED\_COUNT | 4 | Number of times that a highlights album is renamed. | 6428| CHANGED\_COVER\_COUNT | 5 | Number of times that a cover is changed. | 6429| RENDER\_VIEWED\_TIMES | 100 | Number of times that the pictures in a highlights album are played. | 6430| RENDER\_VIEWED\_DURATION | 101 | Time used to play the pictures in a highlights album. | 6431| ART\_LAYOUT\_VIEWED\_TIMES | 102 | Number of times that a highlights album is viewed. | 6432| ART\_LAYOUT\_VIEWED\_DURATION | 103 | Time used to view a highlights album. | 6433 6434## MovingPhotoEffectMode<sup>12+</sup> 6435 6436Enumerates the effects of a moving photo. 6437 6438**System API**: This is a system API. 6439 6440**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6441 6442| Name | Value | Description | 6443| :---------------------------- | :- | :------- | 6444| DEFAULT | 0 | Default effect.| 6445| BOUNCE\_PLAY | 1 | Back-and-forth motion.| 6446| LOOP\_PLAY | 2 | Continuously repeated animation.| 6447| LONG\_EXPOSURE | 3 | Long exposure. | 6448| MULTI\_EXPOSURE | 4 | Multiple exposures. | 6449| CINEMA\_GRAPH<sup>13+</sup> | 5 | Cinemagraph. | 6450| IMAGE\_ONLY<sup>13+</sup> | 10 | Image only. | 6451 6452## PhotoPermissionType<sup>12+</sup> 6453 6454Enumerates the types of permissions for accessing media assets. 6455 6456The permissions include temporary read permission and persistent read permission. The temporary read permission will be removed when the application is dead, while the persistent read permission will not. 6457 6458For the same media asset and application, the persistent read permission overwrites the temporary read permission. The temporary read permission does not overwrite the persistent read permission. 6459 6460**System API**: This is a system API. 6461 6462**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6463 6464| Name | Value| Description| 6465| ----- | ---- | ---- | 6466| TEMPORARY_READ_IMAGEVIDEO | 0 | Temporary read permission.| 6467| PERSISTENT_READ_IMAGEVIDEO | 1 | Persistent read permission.| 6468 6469## HideSensitiveType<sup>12+</sup> 6470 6471Enumerates the types of media resource information to be hidden from an application. 6472 6473**System API**: This is a system API. 6474 6475**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6476 6477| Name | Value| Description| 6478| ----- | ---- | ---- | 6479| HIDE_LOCATION_AND_SHOOTING_PARAM | 0 | Geographical location and shooting parameters.| 6480| HIDE_LOCATION_ONLY | 1 | Geographical location information.| 6481| HIDE_SHOOTING_PARAM_ONLY | 2 | Shooting parameters.| 6482| NO_HIDE_SENSITIVE_TYPE | 3 | Do not hide any information.| 6483 6484## CloudEnhancementTaskStage<sup>13+</sup> 6485 6486Enumerates the cloud enhancement task states, which are returned by [CloudEnhancementTaskState](#cloudenhancement13). 6487 6488**System API**: This is a system API. 6489 6490**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6491 6492| Name | Value| Description| 6493| ----- | ---- | ---- | 6494| TASK_STAGE_EXCEPTION | -1 | The cloud enhancement task is abnormal.| 6495| TASK_STAGE_PREPARING | 0 | The cloud enhancement task is being prepared.| 6496| TASK_STAGE_UPLOADING | 1 | The cloud enhancement task is uploading data.| 6497| TASK_STAGE_EXECUTING | 2 | The cloud enhancement task is being executed.| 6498| TASK_STAGE_DOWNLOADING | 3 | The cloud enhancement task is downloading data.| 6499| TASK_STAGE_FAILED | 4 | The cloud enhancement task failed.| 6500| TASK_STAGE_COMPLETED | 5 | The cloud enhancement task is complete.| 6501 6502## CloudEnhancementState<sup>13+</sup> 6503 6504Enumerates the cloud enhancement states. 6505 6506**System API**: This is a system API. 6507 6508**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6509 6510| Name | Value| Description| 6511| ----- | ---- | ---- | 6512| UNAVAILABLE | 0 | Cloud enhancement is unavailable.| 6513| AVAILABLE | 1 | Cloud enhancement is available.| 6514| EXECUTING | 2 | Cloud enhancement is being executed.| 6515| COMPLETED | 3 | Cloud enhancement has been completed.| 6516 6517## CloudEnhancementTaskState<sup>13+</sup> 6518 6519Represents the cloud enhancement task information, which includes the cloud enhancement task state and other information related to certain states. 6520 6521**System API**: This is a system API. 6522 6523**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6524 6525| Name | Type | Mandatory| Description | 6526| ---------------------- | ------------------- | ---- | ------------------------------------------------ | 6527|taskStage |[CloudEnhancementTaskStage](#cloudenhancementtaskstage13) |Yes| Cloud enhancement task state.| 6528|transferredFileSize |number |No| Size of the file transferred. This parameter is mandatory when **taskStage** is **CloudEnhancementTaskStage.TASK_STAGE_UPLOADING** or **CloudEnhancementTaskStage.TASK_STAGE_DOWNLOADING**. | 6529|totalFileSize |number |No| Total file size. This parameter is mandatory when **taskStage** is **CloudEnhancementTaskStage.TASK_STAGE_UPLOADING** or **CloudEnhancementTaskStage.TASK_STAGE_DOWNLOADING**. | 6530|expectedDuration |number |No| Queuing time. This parameter is mandatory when **taskStage** is **CloudEnhancementTaskStage.TASK_STAGE_EXECUTING**. | 6531|statusCode |number |No| Status code. This parameter is mandatory when **taskStage** is **CloudEnhancementTaskStage.TASK_STAGE_FAILED**. | 6532 6533## VideoEnhancementType<sup>13+</sup> 6534 6535Enumerates the types of segmented video enhancement. 6536 6537**System API**: This is a system API. 6538 6539**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6540 6541| Name | Value| Description| 6542| ----- | ---- | ---- | 6543| QUALITY_ENHANCEMENT_LOCAL | 0 | Apply enhancement on the device.| 6544| QUALITY_ENHANCEMENT_CLOUD | 1 | Apply enhancement on the cloud.| 6545| QUALITY_ENHANCEMENT_LOCAL_AND_CLOUD | 2 | Apply enhancement on both the device and cloud.| 6546 6547## ThumbnailType<sup>13+</sup> 6548 6549Enumerates thumbnail types. 6550 6551**System API**: This is a system API. 6552 6553**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6554 6555| Name | Value | Description | 6556| :---------------------------- | :- | :------- | 6557| LCD | 1 | LCD thumbnail. | 6558| THM | 2 | THM thumbnail. | 6559 6560## WatermarkType<sup>14+</sup> 6561 6562Enumerates the watermark editable flags. 6563 6564**System API**: This is a system API. 6565 6566**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6567 6568| Name | Value| Description| 6569| ----- | ---- | ---- | 6570| DEFAULT | 0 | Watermarks are not editable.| 6571| BRAND_COMMON | 1 | Brand and common watermarks are editable.| 6572| COMMON | 2 | Common watermarks are editable.| 6573| BRAND | 3 | Brand watermarks are editable.| 6574 6575## CloudMediaDownloadType<sup>14+</sup> 6576 6577Enumerates the types of download tasks. 6578 6579**System API**: This is a system API. 6580 6581**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6582 6583| Name | Value| Description| 6584| ----- | ---- | ---- | 6585| DOWNLOAD_FORCE | 0 | High-priority download, without the need for the device to switch to screen-off charging mode.| 6586| DOWNLOAD_GENTLE | 1 | Low-priority download, demanding that device be in screen-off charging mode.| 6587 6588## CloudMediaRetainType<sup>14+</sup> 6589 6590Enumerates the modes used for deleting cloud media assets. 6591 6592**System API**: This is a system API. 6593 6594**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6595 6596| Name | Value| Description| 6597| ----- | ---- | ---- | 6598| RETAIN_FORCE | 0 | Deletes the local metadata and thumbnail of the original files from the cloud.| 6599 6600## CloudMediaAssetTaskStatus<sup>14+</sup> 6601 6602Enumerates the statuses of tasks used for downloading cloud media assets. 6603 6604**System API**: This is a system API. 6605 6606**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6607 6608| Name | Value| Description| 6609| ----- | ---- | ---- | 6610| DOWNLOADING | 0 | The task is in progress.| 6611| PAUSED | 1 | The task is paused.| 6612| IDLE | 2 | There is no download task.| 6613 6614## CloudMediaTaskPauseCause<sup>14+</sup> 6615 6616Enumerates the reasons why a cloud media asset download task is paused. 6617 6618**System API**: This is a system API. 6619 6620**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6621 6622| Name | Value| Description| 6623| ----- | ---- | ---- | 6624| NO_PAUSE | 0 | Downloading is proceeding normally without any pauses.| 6625| TEMPERATURE_LIMIT | 1 | The device temperature is excessively high.| 6626| ROM_LIMIT | 2 | The local disk space is insufficient.| 6627| NETWORK_FLOW_LIMIT | 3 | Network traffic is restricted, and Wi-Fi is not available.| 6628| WIFI_UNAVAILABLE | 4 | The network is abnormal.| 6629| POWER_LIMIT | 5 | Power usage is restricted.| 6630| BACKGROUND_TASK_UNAVAILABLE | 6 | The device is not in charging screen-off mode.| 6631| FREQUENT_USER_REQUESTS | 7 | The user is making requests too frequently.| 6632| CLOUD_ERROR | 8 | There is an error with the cloud service.| 6633| USER_PAUSED | 9 | The download has been paused by the user.| 6634 6635## CloudMediaAssetStatus<sup>14+</sup> 6636 6637Describes the details of a cloud media asset download task. It is the return value of the API used by applications to obtain the cloud asset download task status. 6638 6639**System API**: This is a system API. 6640 6641**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core 6642 6643| Name | Type | Mandatory| Description | 6644| ---------------------- | ------------------- | ---- | ------------------------------------------------ | 6645|taskStatus |[CloudMediaAssetTaskStatus](#cloudmediaassettaskstatus14) |Yes| Status of the download task.| 6646|taskInfo |string |Yes| Total number of and size (measured in bytes) of the assets that have been downloaded, and the total number and size (also measured in bytes) of the assets remaining to be downloaded. | 6647|errorCode |[CloudMediaTaskPauseCause](#cloudmediataskpausecause14) |Yes| Reason why the download task is suspended.| 6648