• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.file.photoAccessHelper (Album Management)
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
9## Modules to Import
10
11```ts
12import { photoAccessHelper } from '@kit.MediaLibraryKit';
13```
14
15## photoAccessHelper.getPhotoAccessHelper
16
17getPhotoAccessHelper(context: Context): PhotoAccessHelper
18
19Obtains a **PhotoAccessHelper** instance for accessing and modifying media files in the album.
20
21**Model restriction**: This API can be used only in the stage model.
22
23**Atomic service API**: This API can be used in atomic services since API version 11.
24
25**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
26
27**Parameters**
28
29| Name | Type   | Mandatory| Description                      |
30| ------- | ------- | ---- | -------------------------- |
31| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
32
33**Return value**
34
35| Type                           | Description   |
36| ----------------------------- | :---- |
37| [PhotoAccessHelper](#photoaccesshelper) | **PhotoAccessHelper** instance obtained.|
38
39**Error codes**
40
41For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
42
43| ID| Error Message|
44| -------- | ---------------------------------------- |
45| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
46
47**Example**
48
49```ts
50// The phAccessHelper instance obtained is a global object. It is used by default in subsequent operations. If the code snippet is not added, an error will be reported indicating that phAccessHelper is not defined.
51let context = getContext(this);
52let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
53```
54
55## PhotoAccessHelper
56
57### getAssets
58
59getAssets(options: FetchOptions, callback: AsyncCallback<FetchResult<PhotoAsset>>): void
60
61Obtains image and video assets. This API uses an asynchronous callback to return the result.
62
63**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
64
65**Required permissions**: ohos.permission.READ_IMAGEVIDEO
66
67When you call this API in Picker mode, you do not need to request the ohos.permission.READ_IMAGEVIDEO permission. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
68
69**Parameters**
70
71| Name  | Type                    | Mandatory| Description                     |
72| -------- | ------------------------ | ---- | ------------------------- |
73| options  | [FetchOptions](#fetchoptions)        | Yes  | Options for fetching the image and video assets.             |
74| callback |  AsyncCallback<[FetchResult](#fetchresult)<[PhotoAsset](#photoasset)>> | Yes  | Callback used to return the image and video assets obtained.|
75
76**Error codes**
77
78For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
79
80| ID| Error Message|
81| -------- | ---------------------------------------- |
82| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
83| 13900012     | Permission denied.         |
84| 13900020     | Invalid argument.         |
85| 14000011       | System inner fail.         |
86
87**Example**
88
89```ts
90import { dataSharePredicates } from '@kit.ArkData';
91
92async function example() {
93  console.info('getAssets');
94  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
95  let fetchOptions: photoAccessHelper.FetchOptions = {
96    fetchColumns: [],
97    predicates: predicates
98  };
99
100  phAccessHelper.getAssets(fetchOptions, async (err, fetchResult) => {
101    if (fetchResult !== undefined) {
102      console.info('fetchResult success');
103      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
104      if (photoAsset !== undefined) {
105        console.info('photoAsset.displayName : ' + photoAsset.displayName);
106      }
107    } else {
108      console.error(`fetchResult fail with error: ${err.code}, ${err.message}`);
109    }
110  });
111}
112```
113
114### getAssets
115
116getAssets(options: FetchOptions): Promise<FetchResult<PhotoAsset>>
117
118Obtains image and video assets. This API uses a promise to return the result.
119
120**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
121
122**Required permissions**: ohos.permission.READ_IMAGEVIDEO
123
124When you call this API in Picker mode, you do not need to request the ohos.permission.READ_IMAGEVIDEO permission. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
125
126**Parameters**
127
128| Name | Type               | Mandatory| Description            |
129| ------- | ------------------- | ---- | ---------------- |
130| options | [FetchOptions](#fetchoptions)   | Yes  | Options for fetching the image and video assets.    |
131
132**Return value**
133
134| Type                       | Description          |
135| --------------------------- | -------------- |
136| Promise<[FetchResult](#fetchresult)<[PhotoAsset](#photoasset)>> | Promise used to return the image and video assets obtained.|
137
138**Error codes**
139
140For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
141
142| ID| Error Message|
143| -------- | ---------------------------------------- |
144| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
145| 13900012     | Permission denied.         |
146| 13900020     | Invalid argument.         |
147| 14000011       | System inner fail.         |
148
149**Example**
150
151```ts
152import { dataSharePredicates } from '@kit.ArkData';
153
154async function example() {
155  console.info('getAssets');
156  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
157  let fetchOptions: photoAccessHelper.FetchOptions = {
158    fetchColumns: [],
159    predicates: predicates
160  };
161  try {
162    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
163    if (fetchResult !== undefined) {
164      console.info('fetchResult success');
165      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
166      if (photoAsset !== undefined) {
167        console.info('photoAsset.displayName :' + photoAsset.displayName);
168      }
169    }
170  } catch (err) {
171    console.error(`getAssets failed, error: ${err.code}, ${err.message}`);
172  }
173}
174```
175
176### getBurstAssets<sup>12+</sup>
177
178getBurstAssets(burstKey: string, options: FetchOptions): Promise&lt;FetchResult&lt;PhotoAsset&gt;&gt;
179
180Obtains burst assets. This API uses a promise to return the result.
181
182**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
183
184**Required permissions**: ohos.permission.READ_IMAGEVIDEO
185
186**Parameters**
187
188| Name | Type               | Mandatory| Description            |
189| ------- | ------------------- | ---- | ---------------- |
190| burstKey | string   | Yes  | UUID of a set of burst photos (**BURST_KEY** of [PhotoKeys](#photokeys)). The value is a string of 36 characters.|
191| options | [FetchOptions](#fetchoptions)   | Yes  | Options for fetching the burst photos.    |
192
193**Return value**
194
195| Type                       | Description          |
196| --------------------------- | -------------- |
197| Promise&lt;[FetchResult](#fetchresult)&lt;[PhotoAsset](#photoasset)&gt;&gt; | Promise used to return the result.|
198
199**Error codes**
200
201For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
202
203| ID| Error Message|
204| -------- | ---------------------------------------- |
205| 201   | Permission denied.         |
206| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
207| 14000011       | Internal system error.         |
208
209**Example**
210
211```ts
212import { photoAccessHelper } from '@kit.MediaLibraryKit';
213import { dataSharePredicates } from '@kit.ArkData';
214
215async function example() {
216  console.info('getBurstAssets');
217  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
218  let fetchOptions: photoAccessHelper.FetchOptions = {
219    fetchColumns: [],
220    predicates: predicates
221  };
222  // burstKey is a 36-bit UUID, which can be obtained from photoAccessHelper.PhotoKeys.
223  let burstKey: string = "e719d696-09fa-44f8-8e9e-ec3f215aa62a";
224  try {
225    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await
226      phAccessHelper.getBurstAssets(burstKey, fetchOptions);
227    if (fetchResult !== undefined) {
228      console.info('fetchResult success');
229      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
230      if (photoAsset !== undefined) {
231        console.info('photoAsset.displayName :' + photoAsset.displayName);
232      }
233    }
234  } catch (err) {
235    console.error(`getBurstAssets failed, error: ${err.code}, ${err.message}`);
236  }
237}
238```
239
240### createAsset
241
242createAsset(photoType: PhotoType, extension: string, options: CreateOptions, callback: AsyncCallback&lt;string&gt;): void
243
244Creates an image or video asset with the specified file type, file name extension, and options. This API uses an asynchronous callback to return the result.
245
246If the caller does not have the ohos.permission.WRITE_IMAGEVIDEO permission, you can create a media asset by using a security component. For details, see [Creating a Media Asset Using a Security Component](../../media/medialibrary/photoAccessHelper-savebutton.md).
247
248**Atomic service API**: This API can be used in atomic services since API version 11.
249
250**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
251
252**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
253
254**Parameters**
255
256| Name  | Type                    | Mandatory| Description                     |
257| -------- | ------------------------ | ---- | ------------------------- |
258| photoType  | [PhotoType](#phototype)        | Yes  | Type of the file to create, which can be **IMAGE** or **VIDEO**.             |
259| extension  | string        | Yes  | File name extension, for example, **'jpg'**.             |
260| options  | [CreateOptions](#createoptions)        | Yes  | Options for creating the image or video asset, for example, **{title: 'testPhoto'}**.             |
261| callback |  AsyncCallback&lt;string&gt; | Yes  | Callback used to return the URI of the created image or video asset.|
262
263**Error codes**
264
265For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
266
267| ID| Error Message|
268| -------- | ---------------------------------------- |
269| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
270| 13900012     | Permission denied.         |
271| 13900020     | Invalid argument.         |
272| 14000011       | System inner fail.         |
273
274**Example**
275
276```ts
277async function example() {
278  console.info('createAssetDemo');
279  let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
280  let extension:string = 'jpg';
281  let options: photoAccessHelper.CreateOptions = {
282    title: 'testPhoto'
283  }
284  phAccessHelper.createAsset(photoType, extension, options, (err, uri) => {
285    if (uri !== undefined) {
286      console.info('createAsset uri' + uri);
287      console.info('createAsset successfully');
288    } else {
289      console.error(`createAsset failed, error: ${err.code}, ${err.message}`);
290    }
291  });
292}
293```
294
295### createAsset
296
297createAsset(photoType: PhotoType, extension: string, callback: AsyncCallback&lt;string&gt;): void
298
299Creates an image or video asset with the specified file type and file name extension. This API uses an asynchronous callback to return the result.
300
301If the caller does not have the ohos.permission.WRITE_IMAGEVIDEO permission, you can create a media asset by using a security component. For details, see [Creating a Media Asset Using a Security Component](../../media/medialibrary/photoAccessHelper-savebutton.md).
302
303**Atomic service API**: This API can be used in atomic services since API version 11.
304
305**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
306
307**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
308
309**Parameters**
310
311| Name  | Type                    | Mandatory| Description                     |
312| -------- | ------------------------ | ---- | ------------------------- |
313| photoType  | [PhotoType](#phototype)        | Yes  | Type of the file to create, which can be **IMAGE** or **VIDEO**.             |
314| extension  | string        | Yes  | File name extension, for example, **'jpg'**.             |
315| callback |  AsyncCallback&lt;string&gt; | Yes  | Callback used to return the URI of the created image or video asset.|
316
317**Error codes**
318
319For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
320
321| ID| Error Message|
322| -------- | ---------------------------------------- |
323| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
324| 13900012     | Permission denied.         |
325| 13900020     | Invalid argument.         |
326| 14000011       | System inner fail.         |
327
328**Example**
329
330```ts
331async function example() {
332  console.info('createAssetDemo');
333  let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
334  let extension: string = 'jpg';
335  phAccessHelper.createAsset(photoType, extension, (err, uri) => {
336    if (uri !== undefined) {
337      console.info('createAsset uri' + uri);
338      console.info('createAsset successfully');
339    } else {
340      console.error(`createAsset failed, error: ${err.code}, ${err.message}`);
341    }
342  });
343}
344```
345
346### createAsset
347
348createAsset(photoType: PhotoType, extension: string, options?: CreateOptions): Promise&lt;string&gt;
349
350Creates an image or video asset with the specified file type, file name extension, and options. This API uses a promise to return the result.
351
352If the caller does not have the ohos.permission.WRITE_IMAGEVIDEO permission, you can create a media asset by using a security component. For details, see [Creating a Media Asset Using a Security Component](../../media/medialibrary/photoAccessHelper-savebutton.md).
353
354**Atomic service API**: This API can be used in atomic services since API version 11.
355
356**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
357
358**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
359
360**Parameters**
361
362| Name  | Type                    | Mandatory| Description                     |
363| -------- | ------------------------ | ---- | ------------------------- |
364| photoType  | [PhotoType](#phototype)        | Yes  | Type of the file to create, which can be **IMAGE** or **VIDEO**.             |
365| extension  | string        | Yes  | File name extension, for example, **'jpg'**.             |
366| options  | [CreateOptions](#createoptions)        | No  | Options for creating the image or video asset, for example, **{title: 'testPhoto'}**.             |
367
368**Return value**
369
370| Type                       | Description          |
371| --------------------------- | -------------- |
372| Promise&lt;string&gt; | Promise used to return the URI of the created image or video asset.|
373
374**Error codes**
375
376For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
377
378| ID| Error Message|
379| -------- | ---------------------------------------- |
380| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
381| 13900012     | Permission denied.         |
382| 13900020     | Invalid argument.         |
383| 14000011       | System inner fail.         |
384
385**Example**
386
387```ts
388async function example() {
389  console.info('createAssetDemo');
390  try {
391    let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
392    let extension: string = 'jpg';
393    let options: photoAccessHelper.CreateOptions = {
394      title: 'testPhoto'
395    }
396    let uri: string = await phAccessHelper.createAsset(photoType, extension, options);
397    console.info('createAsset uri' + uri);
398    console.info('createAsset successfully');
399  } catch (err) {
400    console.error(`createAsset failed, error: ${err.code}, ${err.message}`);
401  }
402}
403```
404
405### getAlbums
406
407getAlbums(type: AlbumType, subtype: AlbumSubtype, options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;Album&gt;&gt;): void
408
409Obtains albums based on the specified options and album type. This API uses an asynchronous callback to return the result.
410
411Before the operation, ensure that the albums to obtain exist.
412
413**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
414
415**Required permissions**: ohos.permission.READ_IMAGEVIDEO
416
417**Parameters**
418
419| Name  | Type                    | Mandatory| Description                     |
420| -------- | ------------------------ | ---- | ------------------------- |
421| type  | [AlbumType](#albumtype)         | Yes  | Type of the album.             |
422| subtype  | [AlbumSubtype](#albumsubtype)         | Yes  | Subtype of the album.             |
423| options  | [FetchOptions](#fetchoptions)         | Yes  |  Options for fetching the albums.             |
424| callback |  AsyncCallback&lt;[FetchResult](#fetchresult)&lt;[Album](#album)&gt;&gt; | Yes  | Callback used to return the result.|
425
426**Error codes**
427
428For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
429
430| ID| Error Message|
431| -------- | ---------------------------------------- |
432| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
433| 13900012     | Permission denied.         |
434| 13900020     | Invalid argument.         |
435| 14000011       | System inner fail.         |
436
437**Example**
438
439```ts
440import { dataSharePredicates } from '@kit.ArkData';
441
442async function example() {
443  // Obtain the album named newAlbumName.
444  console.info('getAlbumsDemo');
445  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
446  predicates.equalTo('album_name', 'newAlbumName');
447  let fetchOptions: photoAccessHelper.FetchOptions = {
448    fetchColumns: [],
449    predicates: predicates
450  };
451  phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions, async (err, fetchResult) => {
452    if (err) {
453      console.error(`getAlbumsCallback failed with err: ${err.code}, ${err.message}`);
454      return;
455    }
456    if (fetchResult === undefined) {
457      console.error('getAlbumsCallback fetchResult is undefined');
458      return;
459    }
460    let album = await fetchResult.getFirstObject();
461    console.info('getAlbumsCallback successfully, albumName: ' + album.albumName);
462    fetchResult.close();
463  });
464}
465```
466
467### getAlbums
468
469getAlbums(type: AlbumType, subtype: AlbumSubtype, callback: AsyncCallback&lt;FetchResult&lt;Album&gt;&gt;): void
470
471Obtains albums by type. This API uses an asynchronous callback to return the result.
472
473Before the operation, ensure that the albums to obtain exist.
474
475**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
476
477**Required permissions**: ohos.permission.READ_IMAGEVIDEO
478
479**Parameters**
480
481| Name  | Type                    | Mandatory| Description                     |
482| -------- | ------------------------ | ---- | ------------------------- |
483| type  | [AlbumType](#albumtype)         | Yes  | Type of the album.             |
484| subtype  | [AlbumSubtype](#albumsubtype)         | Yes  | Subtype of the album.             |
485| callback |  AsyncCallback&lt;[FetchResult](#fetchresult)&lt;[Album](#album)&gt;&gt; | Yes  | Callback used to return the result.|
486
487**Error codes**
488
489For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
490
491| ID| Error Message|
492| -------- | ---------------------------------------- |
493| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
494| 13900012     | Permission denied.         |
495| 13900020     | Invalid argument.         |
496| 14000011       | System inner fail.         |
497
498**Example**
499
500```ts
501async function example() {
502  // Obtain the system album VIDEO, which is preset by default.
503  console.info('getAlbumsDemo');
504  phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.VIDEO, async (err, fetchResult) => {
505    if (err) {
506      console.error(`getAlbumsCallback failed with err: ${err.code}, ${err.message}`);
507      return;
508    }
509    if (fetchResult === undefined) {
510      console.error('getAlbumsCallback fetchResult is undefined');
511      return;
512    }
513    let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
514    console.info('getAlbumsCallback successfully, albumUri: ' + album.albumUri);
515    fetchResult.close();
516  });
517}
518```
519
520### getAlbums
521
522getAlbums(type: AlbumType, subtype: AlbumSubtype, options?: FetchOptions): Promise&lt;FetchResult&lt;Album&gt;&gt;
523
524Obtains albums based on the specified options and album type. This API uses a promise to return the result.
525
526Before the operation, ensure that the albums to obtain exist.
527
528**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
529
530**Required permissions**: ohos.permission.READ_IMAGEVIDEO
531
532**Parameters**
533
534| Name  | Type                    | Mandatory| Description                     |
535| -------- | ------------------------ | ---- | ------------------------- |
536| type  | [AlbumType](#albumtype)         | Yes  | Type of the album.             |
537| subtype  | [AlbumSubtype](#albumsubtype)         | Yes  | Subtype of the album.             |
538| options  | [FetchOptions](#fetchoptions)         | No  |  Options for fetching the albums. If this parameter is not specified, the albums are obtained based on the album type by default.             |
539
540**Return value**
541
542| Type                       | Description          |
543| --------------------------- | -------------- |
544| Promise&lt;[FetchResult](#fetchresult)&lt;[Album](#album)&gt;&gt; | Promise used to return the result.|
545
546**Error codes**
547
548For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
549
550| ID| Error Message|
551| -------- | ---------------------------------------- |
552| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
553| 13900012     | Permission denied.         |
554| 13900020     | Invalid argument.         |
555| 14000011       | System inner fail.         |
556
557**Example**
558
559```ts
560import { dataSharePredicates } from '@kit.ArkData';
561import { BusinessError } from '@kit.BasicServicesKit';
562
563async function example() {
564  // Obtain the album named newAlbumName.
565  console.info('getAlbumsDemo');
566  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
567  predicates.equalTo('album_name', 'newAlbumName');
568  let fetchOptions: photoAccessHelper.FetchOptions = {
569    fetchColumns: [],
570    predicates: predicates
571  };
572  phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions).then( async (fetchResult) => {
573    if (fetchResult === undefined) {
574      console.error('getAlbumsPromise fetchResult is undefined');
575      return;
576    }
577    let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
578    console.info('getAlbumsPromise successfully, albumName: ' + album.albumName);
579    fetchResult.close();
580  }).catch((err: BusinessError) => {
581    console.error(`getAlbumsPromise failed with err: ${err.code}, ${err.message}`);
582  });
583}
584```
585
586### registerChange
587
588registerChange(uri: string, forChildUris: boolean, callback: Callback&lt;ChangeData&gt;) : void
589
590Registers listening for the specified URI. This API uses a callback to return the result.
591
592**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
593
594**Parameters**
595
596| Name   | Type                                       | Mandatory| Description                                                        |
597| --------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
598| uri       | string                                      | Yes  | URI of the photo asset, URI of the album, or [DefaultChangeUri](#defaultchangeuri).|
599| forChildUris | boolean                                     | Yes  | Whether to perform fuzzy listening.<br>If **uri** is the URI of an album, the value **true** means to listen for the changes of the files in the album; the value **false** means to listen for the changes of the album only.<br>If **uri** is the URI of a photoAsset, there is no difference between **true** and false for **forChildUris**.<br>If **uri** is **DefaultChangeUri**, **forChildUris** must be set to **true**. If **forChildUris** is false, the URI cannot be found and no message can be received.|
600| callback  | Callback&lt;[ChangeData](#changedata)&gt; | Yes  | Callback used to return the [ChangeData](#changedata). <br>**NOTE**<br>Multiple callback listeners can be registered for a URI. You can use [unRegisterChange](#unregisterchange) to unregister all listeners for the URI or a specified callback listener.|
601
602**Error codes**
603
604For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
605
606| ID| Error Message|
607| -------- | ---------------------------------------- |
608| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
609| 13900012     | Permission denied.         |
610| 13900020     | Invalid argument.         |
611
612**Example**
613
614```ts
615import { dataSharePredicates } from '@kit.ArkData';
616
617async function example() {
618  console.info('registerChangeDemo');
619  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
620  let fetchOptions: photoAccessHelper.FetchOptions = {
621    fetchColumns: [],
622    predicates: predicates
623  };
624  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
625  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
626  if (photoAsset !== undefined) {
627    console.info('photoAsset.displayName : ' + photoAsset.displayName);
628  }
629  let onCallback1 = (changeData: photoAccessHelper.ChangeData) => {
630      console.info('onCallback1 success, changData: ' + JSON.stringify(changeData));
631    //file had changed, do something.
632  }
633  let onCallback2 = (changeData: photoAccessHelper.ChangeData) => {
634      console.info('onCallback2 success, changData: ' + JSON.stringify(changeData));
635    //file had changed, do something.
636  }
637  // Register onCallback1.
638  phAccessHelper.registerChange(photoAsset.uri, false, onCallback1);
639  // Register onCallback2.
640  phAccessHelper.registerChange(photoAsset.uri, false, onCallback2);
641
642  await photoAccessHelper.MediaAssetChangeRequest.deleteAssets(context, [photoAsset]);
643}
644```
645
646### unRegisterChange
647
648unRegisterChange(uri: string, callback?: Callback&lt;ChangeData&gt;): void
649
650Unregisters listening for the specified URI. Multiple callbacks can be registered for a URI for listening. You can use this API to unregister the listening of the specified callbacks or all callbacks.
651
652**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
653
654**Parameters**
655
656| Name  | Type                                       | Mandatory| Description                                                        |
657| -------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
658| uri      | string                                      | Yes  | URI of the photo asset, URI of the album, or [DefaultChangeUri](#defaultchangeuri).|
659| callback | Callback&lt;[ChangeData](#changedata)&gt; | No  | Callback to unregister. If this parameter is not specified, all the callbacks for listening for the URI will be canceled. <br>**NOTE**: The specified callback unregistered will not be invoked when the data changes.|
660
661**Error codes**
662
663For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
664
665| ID| Error Message|
666| -------- | ---------------------------------------- |
667| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
668| 13900012     | Permission denied.         |
669| 13900020     | Invalid argument.         |
670
671**Example**
672
673```ts
674import { dataSharePredicates } from '@kit.ArkData';
675
676async function example() {
677  console.info('offDemo');
678  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
679  let fetchOptions: photoAccessHelper.FetchOptions = {
680    fetchColumns: [],
681    predicates: predicates
682  };
683  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
684  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
685  if (photoAsset !== undefined) {
686    console.info('photoAsset.displayName : ' + photoAsset.displayName);
687  }
688  let onCallback1 = (changeData: photoAccessHelper.ChangeData) => {
689    console.info('onCallback1 on');
690  }
691  let onCallback2 = (changeData: photoAccessHelper.ChangeData) => {
692    console.info('onCallback2 on');
693  }
694  // Register onCallback1.
695  phAccessHelper.registerChange(photoAsset.uri, false, onCallback1);
696  // Register onCallback2.
697  phAccessHelper.registerChange(photoAsset.uri, false, onCallback2);
698  // Unregister the listening of onCallback1.
699  phAccessHelper.unRegisterChange(photoAsset.uri, onCallback1);
700  await photoAccessHelper.MediaAssetChangeRequest.deleteAssets(context, [photoAsset]);
701}
702```
703
704### createDeleteRequest<sup>(deprecated)</sup>
705
706createDeleteRequest(uriList: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void
707
708Creates a dialog box for deleting media files. This API uses an asynchronous callback to return the result. The deleted media files are moved to the trash.
709
710> **NOTE**
711>
712> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.deleteAssets](#deleteassets11-1) instead.
713
714**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
715
716**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
717
718**Parameters**
719
720| Name  | Type                     | Mandatory| Description      |
721| -------- | ------------------------- | ---- | ---------- |
722| uriList | Array&lt;string&gt; | Yes  | URIs of the media files to delete. A maximum of 300 media files can be deleted.|
723| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
724
725**Error codes**
726
727For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
728
729| ID| Error Message|
730| -------- | ---------------------------------------- |
731| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
732| 13900012     | Permission denied.         |
733| 13900020     | Invalid argument.         |
734| 14000011       | System inner fail.         |
735
736**Example**
737
738```ts
739import { dataSharePredicates } from '@kit.ArkData';
740
741async function example() {
742  console.info('createDeleteRequestDemo');
743  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
744  let fetchOptions: photoAccessHelper.FetchOptions = {
745    fetchColumns: [],
746    predicates: predicates
747  };
748  try {
749    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
750    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
751    if (asset === undefined) {
752      console.error('asset not exist');
753      return;
754    }
755    phAccessHelper.createDeleteRequest([asset.uri], (err) => {
756      if (err === undefined) {
757        console.info('createDeleteRequest successfully');
758      } else {
759        console.error(`createDeleteRequest failed with error: ${err.code}, ${err.message}`);
760      }
761    });
762  } catch (err) {
763    console.error(`fetch failed, error: ${err.code}, ${err.message}`);
764  }
765}
766```
767
768### createDeleteRequest<sup>(deprecated)</sup>
769
770createDeleteRequest(uriList: Array&lt;string&gt;): Promise&lt;void&gt;
771
772Creates a dialog box for deleting media files. This API uses a promise to return the result. The deleted media files are moved to the trash.
773
774> **NOTE**
775>
776> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAssetChangeRequest.deleteAssets](#deleteassets11-1) instead.
777
778**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
779
780**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
781
782**Parameters**
783
784| Name  | Type                     | Mandatory| Description      |
785| -------- | ------------------------- | ---- | ---------- |
786| uriList | Array&lt;string&gt; | Yes  | URIs of the media files to delete. A maximum of 300 media files can be deleted.|
787
788**Return value**
789
790| Type                                   | Description             |
791| --------------------------------------- | ----------------- |
792| Promise&lt;void&gt;| Promise that returns no value.|
793
794**Error codes**
795
796For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
797
798| ID| Error Message|
799| -------- | ---------------------------------------- |
800| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
801| 13900012     | Permission denied.         |
802| 13900020     | Invalid argument.         |
803| 14000011       | System inner fail.         |
804
805**Example**
806
807```ts
808import { dataSharePredicates } from '@kit.ArkData';
809
810async function example() {
811  console.info('createDeleteRequestDemo');
812  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
813  let fetchOptions: photoAccessHelper.FetchOptions = {
814    fetchColumns: [],
815    predicates: predicates
816  };
817  try {
818    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
819    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
820    if (asset === undefined) {
821      console.error('asset not exist');
822      return;
823    }
824    await phAccessHelper.createDeleteRequest([asset.uri]);
825    console.info('createDeleteRequest successfully');
826  } catch (err) {
827    console.error(`createDeleteRequest failed with error: ${err.code}, ${err.message}`);
828  }
829}
830```
831
832### applyChanges<sup>11+</sup>
833
834applyChanges(mediaChangeRequest: MediaChangeRequest): Promise&lt;void&gt;
835
836Applies media changes. This API uses a promise to return the result.
837
838**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
839
840When you create a media asset by using a security component, you do not need to request the ohos.permission.WRITE_IMAGEVIDEO permission to call this API. For details, see [Creating a Media Asset Using a Security Component](../../media/medialibrary/photoAccessHelper-savebutton.md).
841
842**Atomic service API**: This API can be used in atomic services since API version 11.
843
844**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
845
846**Parameters**
847
848| Name  | Type                    | Mandatory| Description                     |
849| -------- | ------------------------ | ---- | ------------------------- |
850| mediaChangeRequest  | [MediaChangeRequest](#mediachangerequest11)  | Yes |  Request for asset changes or album changes.|
851
852**Return value**
853
854| Type                                   | Description             |
855| --------------------------------------- | ----------------- |
856| Promise&lt;void&gt;| Promise that returns no value.|
857
858**Error codes**
859
860For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
861
862| ID| Error Message|
863| -------- | ---------------------------------------- |
864| 201   | Permission denied.         |
865| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
866| 14000011  | System inner fail.     |
867
868**Example**
869
870This API depends on the [MediaChangeRequest](#mediachangerequest11) object. For details about the sample code, see the examples of [MediaAssetChangeRequest](#mediaassetchangerequest11) and [MediaAlbumChangeRequest](#mediaalbumchangerequest11).
871
872### release
873
874release(callback: AsyncCallback&lt;void&gt;): void
875
876Releases this **PhotoAccessHelper** instance. This API uses an asynchronous callback to return the result.
877Call this API when the APIs of the **PhotoAccessHelper** instance are no longer used.
878
879**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
880
881**Parameters**
882
883| Name  | Type                     | Mandatory| Description                |
884| -------- | ------------------------- | ---- | -------------------- |
885| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
886
887**Error codes**
888
889For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
890
891| ID| Error Message|
892| -------- | ---------------------------------------- |
893| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
894| 13900020     | Invalid argument.         |
895| 14000011       | System inner fail.         |
896
897**Example**
898
899```ts
900async function example() {
901  console.info('releaseDemo');
902  phAccessHelper.release((err) => {
903    if (err !== undefined) {
904      console.error(`release failed. error: ${err.code}, ${err.message}`);
905    } else {
906      console.info('release ok.');
907    }
908  });
909}
910```
911
912### release
913
914release(): Promise&lt;void&gt;
915
916Releases this **PhotoAccessHelper** instance. This API uses a promise to return the result.
917Call this API when the APIs of the **PhotoAccessHelper** instance are no longer used.
918
919**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
920
921**Return value**
922
923| Type               | Description                             |
924| ------------------- | --------------------------------- |
925| Promise&lt;void&gt; | Promise that returns no value.|
926
927**Error codes**
928
929For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
930
931| ID| Error Message|
932| -------- | ---------------------------------------- |
933| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
934| 13900020     | Invalid argument.         |
935| 14000011       | System inner fail.         |
936
937**Example**
938
939```ts
940async function example() {
941  console.info('releaseDemo');
942  try {
943    await phAccessHelper.release();
944    console.info('release ok.');
945  } catch (err) {
946    console.error(`release failed. error: ${err.code}, ${err.message}`);
947  }
948}
949```
950
951### showAssetsCreationDialog<sup>12+</sup>
952
953showAssetsCreationDialog(srcFileUris: Array&lt;string&gt;, photoCreationConfigs: Array&lt;PhotoCreationConfig&gt;): Promise&lt;Array&lt;string&gt;&gt;
954
955Shows the dialog box for the user to confirm whether to save the photos or videos. If the user agrees to save the images or videos, a list of URIs granted with the save permission is returned. The list takes effect permanently, and the application can write the images or videos based on the URIs. If the user refuses to save the images or videos, an empty list is returned. To display the application name in the dialog box, the API relies on the configuration of **label** and **icon** under **abilities** in the **module.json5** file. If they are not configured, no application name is displayed in the dialog box.
956
957> **NOTE**
958>
959> If the passed URI is a sandbox path, photos or videos can be saved but cannot be previewed.
960
961**Atomic service API**: This API can be used in atomic services since API version 12.
962
963**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
964
965**Parameters**
966
967| Name  | Type                                                                  | Mandatory| Description                     |
968| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
969| srcFileUris | Array&lt;string&gt; | Yes| [URIs](../../file-management/user-file-uri-intro.md#media-file-uri) of the images or videos to be saved to the media library.<br>**NOTE**<br>- Only image and video URIs are supported.<br>- URIs cannot be manually constructed. You must call APIs to obtain them. For details, see [Obtaining a Media File URI](../../file-management/user-file-uri-intro.md#obtaining-a-media-file-uri). |
970| photoCreationConfigs | Array&lt;[PhotoCreationConfig](#photocreationconfig12)&gt; | Yes| Configuration for saving the images or videos, including the names of the files to be saved. The value must be consistent with that of **srcFileUris**.|
971
972**Return value**
973
974| Type                                   | Description             |
975| --------------------------------------- | ----------------- |
976| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return a URI list. The URIs are granted with the permission for the application to write data. If the URIs fail to be generated, a batch creation error code will be returned.<br>The error code **-3006** means that there are invalid characters; **-2004** means that the image type does not match the file name extension; **-203** means that the file operation is abnormal.|
977
978**Error codes**
979
980For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
981
982| ID| Error Message|
983| -------- | ---------------------------------------- |
984| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
985| 14000011 |  Internal system error. |
986
987**Example**
988
989```ts
990import { dataSharePredicates } from '@kit.ArkData';
991import { photoAccessHelper } from '@kit.MediaLibraryKit';
992
993async function example() {
994  console.info('ShowAssetsCreationDialogDemo.');
995
996  try {
997    // Obtain the sandbox URIs of the images or videos to be saved to the media library.
998    let srcFileUris: Array<string> = [
999      'file://fileUriDemo1' // The URI here is an example only.
1000    ];
1001    let photoCreationConfigs: Array<photoAccessHelper.PhotoCreationConfig> = [
1002      {
1003        title: 'test2', // Optional.
1004        fileNameExtension: 'jpg',
1005        photoType: photoAccessHelper.PhotoType.IMAGE,
1006        subtype: photoAccessHelper.PhotoSubtype.DEFAULT, // This parameter is optional.
1007      }
1008    ];
1009    let desFileUris: Array<string> = await phAccessHelper.showAssetsCreationDialog(srcFileUris, photoCreationConfigs);
1010    console.info('showAssetsCreationDialog success, data is ' + desFileUris);
1011  } catch (err) {
1012    console.error('showAssetsCreationDialog failed, errCode is ' + err.code + ', errMsg is ' + err.message);
1013  }
1014}
1015```
1016
1017### createAssetWithShortTermPermission<sup>12+</sup>
1018
1019createAssetWithShortTermPermission(photoCreationConfig: PhotoCreationConfig): Promise&lt;string&gt;
1020
1021Creates an asset with a temporary permission of the given period. When this API is called by an application for the first time, a dialog box will be displayed for the user to confirm whether to save the asset. If the user agrees to save the asset, the asset instance will be created and the file URI granted with the save permission will be returned. The application can write the asset based on the URI
1022within 5 minutes after the user agrees to save the asset. If the same application calls this API again within the 5 minutes, the authorized URI can be automatically returned without the need to display the conformation dialog box.
1023
1024**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1025
1026**Required permissions**: ohos.permission.SHORT_TERM_WRITE_IMAGEVIDEO
1027
1028**Parameters**
1029
1030| Name  | Type                                                                  | Mandatory| Description                     |
1031| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
1032| photoCreationConfig | [PhotoCreationConfig](#photocreationconfig12); | Yes| Configuration for saving a media asset (image or video) to the media library, including the file name.|
1033
1034**Return value**
1035
1036| Type                                   | Description             |
1037| --------------------------------------- | ----------------- |
1038| Promise&lt;string&gt; | Promise used to return the URI of the asset saved. The URIs are granted with the permission for the application to write data. If the URIs fail to be generated, a batch creation error code will be returned.<br>The error code **-3006** means that there are invalid characters; **-2004** means that the image type does not match the file name extension; **-203** means that the file operation is abnormal.|
1039
1040**Error codes**
1041
1042For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1043
1044| ID| Error Message|
1045| -------- | ---------------------------------------- |
1046| 201 | Permission denied |
1047| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1048| 14000011 |  Internal system error |
1049
1050**Example**
1051
1052```ts
1053import { fileIo } from '@kit.CoreFileKit';
1054
1055async function example() {
1056    console.info('createAssetWithShortTermPermissionDemo.');
1057
1058    try {
1059        let photoCreationConfig: photoAccessHelper.PhotoCreationConfig = {
1060            title: '123456',
1061            fileNameExtension: 'jpg',
1062            photoType: photoAccessHelper.PhotoType.IMAGE,
1063            subtype: photoAccessHelper.PhotoSubtype.DEFAULT,
1064        };
1065
1066        let resultUri: string = await phAccessHelper.createAssetWithShortTermPermission(photoCreationConfig);
1067        let resultFile: fileIo.File = fileIo.openSync(resultUri, fileIo.OpenMode.READ_WRITE);
1068        // Use the actual URI and file size.
1069        let srcFile:  fileIo.File = fileIo.openSync("file://test.jpg", fileIo.OpenMode.READ_ONLY);
1070        let bufSize: number = 2000000;
1071        let readSize: number = 0;
1072        let buf = new ArrayBuffer(bufSize);
1073        let readLen = fileIo.readSync(srcFile.fd, buf, {
1074            offset: readSize,
1075            length: bufSize
1076        });
1077        if (readLen > 0) {
1078            readSize += readLen;
1079            fileIo.writeSync(resultFile.fd, buf, { length: readLen });
1080        }
1081        fileIo.closeSync(srcFile);
1082        fileIo.closeSync(resultFile);
1083    } catch (err) {
1084        console.error('createAssetWithShortTermPermission failed, errCode is ' + err.code + ', errMsg is ' + err.message);
1085    }
1086
1087}
1088```
1089
1090### requestPhotoUrisReadPermission<sup>14+</sup>
1091
1092requestPhotoUrisReadPermission(srcFileUris: Array&lt;string&gt;): Promise&lt;Array&lt;string&gt;&gt;
1093
1094<!--RP1--><!--RP1End-->Grants the save permission for URIs. This API uses a promise to return the result.
1095
1096**Atomic service API**: This API can be used in atomic services since API version 14.
1097
1098**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1099
1100**Parameters**
1101
1102| Name  | Type                                                                  | Mandatory| Description                     |
1103| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
1104| srcFileUris | Array&lt;string&gt; | Yes| [URIs](../../file-management/user-file-uri-intro.md#media-file-uri) of the images or videos to be granted with the permission.<br>**NOTE**: Only image and video URIs are supported.|
1105
1106**Return value**
1107
1108| Type                                   | Description             |
1109| --------------------------------------- | ----------------- |
1110| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the URIs granted with the save permission.|
1111
1112**Error codes**
1113
1114For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1115
1116| ID| Error Message|
1117| -------- | ---------------------------------------- |
1118| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1119| 14000011 |  Internal system error |
1120
1121**Example**
1122
1123```ts
1124import { dataSharePredicates } from '@kit.ArkData';
1125import { photoAccessHelper } from '@kit.MediaLibraryKit';
1126
1127async function example() {
1128  console.info('requestPhotoUrisReadPermissionDemo.');
1129
1130  try {
1131    let phAccessHelper: photoAccessHelper.PhotoAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
1132    // Obtain the URIs of the images or videos to be granted with the permission.
1133    let srcFileUris: Array<string> = [
1134      'file://fileUriDemo1' // The URI here is an example only.
1135    ];
1136    let desFileUris: Array<string> = await phAccessHelper.requestPhotoUrisReadPermission(srcFileUris);
1137    console.info('requestPhotoUrisReadPermission success, data is ' + desFileUris);
1138  } catch (err) {
1139    console.error('requestPhotoUrisReadPermission failed, errCode is ' + err.code + ', errMsg is ' + err.message);
1140  }
1141}
1142```
1143
1144### getSupportedPhotoFormats<sup>18+</sup>
1145
1146getSupportedPhotoFormats(photoType: PhotoType): Promise&lt;Array&lt;string&gt;&gt;
1147
1148Obtains the list of image or video file name extensions supported by the media library.
1149
1150**Atomic service API**: This API can be used in atomic services since API version 18.
1151
1152**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1153
1154**Parameters**
1155
1156| Name  | Type                  | Mandatory| Description     |
1157|-----------|-------------------------|-----------|-----------------|
1158| photoType | [PhotoType](#phototype) | Yes  | Type of the file.|
1159
1160**Return value**
1161
1162| Type                                    | Description             |
1163|------------------------------------------|-------------------------|
1164| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return an array of the supported image or video file name extensions.|
1165
1166**Error codes**
1167
1168For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1169
1170| ID| Error Message|
1171| -------- | ---------------------------------------- |
1172| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1173| 14000011 | Internal system error. It is recommended to retry and check the logs. |
1174
1175**Example**
1176
1177```ts
1178import photoAccessHelper from '@ohos.file.photoAccessHelper';
1179
1180async function example(photoTypeNumber: number){
1181  console.info('getSupportedPhotoFormatsDemo.');
1182
1183  try {
1184    let outputText: string;
1185    if (photoTypeNumber !== 1 && photoTypeNumber !== 2) {
1186      outputText = 'Does not support querying formats other than images or videos';
1187      return;
1188    }
1189    outputText = 'The supported types are:\n';
1190    let imageFormat  = await phAccessHelper.getSupportedPhotoFormats(photoTypeNumber);
1191    let result = "";
1192    for (let i = 0; i < imageFormat.length; i++) {
1193      result += imageFormat[i];
1194      if (i !== imageFormat.length - 1) {
1195        result += ', ';
1196      }
1197    }
1198    outputText += result;
1199    console.info('getSupportedPhotoFormats success, data is ' + outputText);
1200  } catch (error) {
1201    console.error('getSupportedPhotoFormats failed, errCode is', error);
1202  }
1203}
1204```
1205
1206## PhotoAsset
1207
1208Provides APIs for encapsulating file asset attributes.
1209
1210### Properties
1211
1212**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1213
1214| Name                     | Type                    | Readable| Writable| Description                                                  |
1215| ------------------------- | ------------------------ | ---- | ---- | ------------------------------------------------------ |
1216| uri                       | string                   | Yes  | No  | Media asset URI, for example, **file://media/Photo/1/IMG_datetime_0001/displayName.jpg**. For details, see [Media File URI](../../file-management/user-file-uri-intro.md#media-file-uri).<br>**Atomic service API**: This API can be used in atomic services since API version 12.        |
1217| photoType   | [PhotoType](#phototype) | Yes  | No  | Type of the file.                                              |
1218| displayName               | string                   | Yes  | No  | File name, including the file name extension, to display. The value contains 1 to 255 characters.                                |
1219
1220### get
1221
1222get(member: string): MemberType
1223
1224Obtains a **PhotoAsset** member parameter.
1225
1226**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1227
1228**Parameters**
1229
1230| Name     | Type                       | Mandatory  | Description   |
1231| -------- | ------------------------- | ---- | ----- |
1232| member | string | Yes   | Name of the member parameter to obtain. Except **'uri'**, **'media_type'**, **'subtype'**, and **'display_name'**, you need to pass in [PhotoKeys](#photokeys) in **fetchColumns** in **get()**. For example, to obtain the title attribute, set **fetchColumns: ['title']**.|
1233
1234**Return value**
1235
1236| Type               | Description                             |
1237| ------------------- | --------------------------------- |
1238| [MemberType](#membertype) | **PhotoAsset** member parameter obtained.|
1239
1240**Error codes**
1241
1242For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1243
1244| ID| Error Message|
1245| -------- | ---------------------------------------- |
1246| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1247| 13900020     | Invalid argument.         |
1248| 14000014     | Member is not a valid PhotoKey.         |
1249
1250**Example**
1251
1252```ts
1253import { dataSharePredicates } from '@kit.ArkData';
1254
1255async function example() {
1256  console.info('photoAssetGetDemo');
1257  try {
1258    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1259    let fetchOption: photoAccessHelper.FetchOptions = {
1260      fetchColumns: ['title'],
1261      predicates: predicates
1262    };
1263    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1264    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1265    let title: photoAccessHelper.PhotoKeys = photoAccessHelper.PhotoKeys.TITLE;
1266    let photoAssetTitle: photoAccessHelper.MemberType = photoAsset.get(title.toString());
1267    console.info('photoAsset Get photoAssetTitle = ', photoAssetTitle);
1268  } catch (err) {
1269    console.error(`release failed. error: ${err.code}, ${err.message}`);
1270  }
1271}
1272```
1273
1274### set
1275
1276set(member: string, value: string): void
1277
1278Sets a **PhotoAsset** member parameter.
1279
1280**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1281
1282**Parameters**
1283
1284| Name     | Type                       | Mandatory  | Description   |
1285| -------- | ------------------------- | ---- | ----- |
1286| member | string | Yes   | Name of the member parameter to set. For example, **[PhotoKeys](#photokeys).TITLE**. The value contains 1 to 255 characters.|
1287| value | string | Yes   | Member parameter to set. Only the value of **[PhotoKeys](#photokeys).TITLE** can be modified. The title must meet the following requirements:<br>- It does not contain a file name extension.<br>- The file name, which is in the format of title+file name extension, does not exceed 255 characters.<br>- The title does not contain any of the following characters:\ / : * ? " ' ` < > \| { } [ ]  |
1288
1289**Error codes**
1290
1291For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1292
1293| ID| Error Message|
1294| -------- | ---------------------------------------- |
1295| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1296| 13900020     | Invalid argument.         |
1297| 14000014     | Member is not a valid PhotoKey.         |
1298
1299**Example**
1300
1301```ts
1302import { dataSharePredicates } from '@kit.ArkData';
1303
1304async function example() {
1305  console.info('photoAssetSetDemo');
1306  try {
1307    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1308    let fetchOption: photoAccessHelper.FetchOptions = {
1309      fetchColumns: ['title'],
1310      predicates: predicates
1311    };
1312    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1313    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1314    let title: string = photoAccessHelper.PhotoKeys.TITLE.toString();
1315    photoAsset.set(title, 'newTitle');
1316  } catch (err) {
1317    console.error(`release failed. error: ${err.code}, ${err.message}`);
1318  }
1319}
1320```
1321
1322### commitModify
1323
1324commitModify(callback: AsyncCallback&lt;void&gt;): void
1325
1326Commits the modification on the file metadata to the database. This API uses an asynchronous callback to return the result.
1327
1328**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
1329
1330**Atomic service API**: This API can be used in atomic services since API version 11.
1331
1332**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1333
1334**Parameters**
1335
1336| Name     | Type                       | Mandatory  | Description   |
1337| -------- | ------------------------- | ---- | ----- |
1338| callback | AsyncCallback&lt;void&gt; | Yes   | Callback that returns no value.|
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| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1347| 13900012     | Permission denied.         |
1348| 13900020     | Invalid argument.         |
1349| 14000001      | Invalid display name.         |
1350| 14000011       | System inner fail.         |
1351
1352**Example**
1353
1354```ts
1355import { dataSharePredicates } from '@kit.ArkData';
1356
1357async function example() {
1358  console.info('commitModifyDemo');
1359  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1360  let fetchOption: photoAccessHelper.FetchOptions = {
1361    fetchColumns: ['title'],
1362    predicates: predicates
1363  };
1364  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1365  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1366  let title: string = photoAccessHelper.PhotoKeys.TITLE.toString();
1367  let photoAssetTitle: photoAccessHelper.MemberType = photoAsset.get(title);
1368  console.info('photoAsset get photoAssetTitle = ', photoAssetTitle);
1369  photoAsset.set(title, 'newTitle2');
1370  photoAsset.commitModify((err) => {
1371    if (err === undefined) {
1372      let newPhotoAssetTitle: photoAccessHelper.MemberType = photoAsset.get(title);
1373      console.info('photoAsset get newPhotoAssetTitle = ', newPhotoAssetTitle);
1374    } else {
1375      console.error(`commitModify failed, error: ${err.code}, ${err.message}`);
1376    }
1377  });
1378}
1379```
1380
1381### commitModify
1382
1383commitModify(): Promise&lt;void&gt;
1384
1385Commits the modification on the file metadata to the database. This API uses a promise to return the result.
1386
1387**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
1388
1389**Atomic service API**: This API can be used in atomic services since API version 11.
1390
1391**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1392
1393**Return value**
1394
1395| Type                 | Description        |
1396| ------------------- | ---------- |
1397| Promise&lt;void&gt; | Promise that returns no value.|
1398
1399**Error codes**
1400
1401For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1402
1403| ID| Error Message|
1404| -------- | ---------------------------------------- |
1405| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1406| 13900012     | Permission denied.         |
1407| 13900020     | Invalid argument.         |
1408| 14000001      | Invalid display name.         |
1409| 14000011       | System inner fail.         |
1410
1411**Example**
1412
1413```ts
1414import { dataSharePredicates } from '@kit.ArkData';
1415
1416async function example() {
1417  console.info('commitModifyDemo');
1418  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1419  let fetchOption: photoAccessHelper.FetchOptions = {
1420    fetchColumns: ['title'],
1421    predicates: predicates
1422  };
1423  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1424  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1425  let title: string = photoAccessHelper.PhotoKeys.TITLE.toString();
1426  let photoAssetTitle: photoAccessHelper.MemberType = photoAsset.get(title);
1427  console.info('photoAsset get photoAssetTitle = ', photoAssetTitle);
1428  photoAsset.set(title, 'newTitle3');
1429  try {
1430    await photoAsset.commitModify();
1431    let newPhotoAssetTitle: photoAccessHelper.MemberType = photoAsset.get(title);
1432    console.info('photoAsset get newPhotoAssetTitle = ', newPhotoAssetTitle);
1433  } catch (err) {
1434    console.error(`release failed. error: ${err.code}, ${err.message}`);
1435  }
1436}
1437```
1438
1439### getReadOnlyFd<sup>(deprecated)</sup>
1440
1441getReadOnlyFd(callback: AsyncCallback&lt;number&gt;): void
1442
1443Opens this file in read-only mode. This API uses an asynchronous callback to return the result.
1444
1445> **NOTE**
1446>
1447> - 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.
1448>
1449> - The returned FD must be closed when it is not required.
1450
1451**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1452
1453**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1454
1455**Parameters**
1456
1457| Name     | Type                         | Mandatory  | Description                                 |
1458| -------- | --------------------------- | ---- | ----------------------------------- |
1459| callback | AsyncCallback&lt;number&gt; | Yes   | Callback used to return the file descriptor (FD) of the file opened.                           |
1460
1461**Error codes**
1462
1463For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1464
1465| ID| Error Message|
1466| -------- | ---------------------------------------- |
1467| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1468| 13900012     | Permission denied.         |
1469| 13900020     | Invalid argument.         |
1470| 14000011       | System inner fail.         |
1471
1472**Example**
1473
1474```ts
1475async function example() {
1476  console.info('getReadOnlyFdDemo');
1477  // Ensure that there are images and video files in the device.
1478  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1479  let fetchOptions: photoAccessHelper.FetchOptions = {
1480    fetchColumns: [],
1481    predicates: predicates
1482  };
1483  let assetResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1484  let photoAsset: photoAccessHelper.PhotoAsset = await assetResult.getFirstObject();
1485  photoAsset.getReadOnlyFd((err, fd) => {
1486    if (fd !== undefined) {
1487      console.info('File fd' + fd);
1488      photoAsset.close(fd);
1489    } else {
1490      console.error(`getReadOnlyFd err: ${err.code}, ${err.message}`);
1491    }
1492  });
1493}
1494```
1495
1496### getReadOnlyFd<sup>(deprecated)</sup>
1497
1498getReadOnlyFd(): Promise&lt;number&gt;
1499
1500Opens this file in read-only mode. This API uses a promise to return the result.
1501
1502> **NOTE**
1503>
1504> - 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.
1505>
1506> - The returned FD must be closed when it is not required.
1507
1508**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1509
1510**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1511
1512**Return value**
1513
1514| Type                   | Description           |
1515| --------------------- | ------------- |
1516| Promise&lt;number&gt; | Promise used to return the FD of the file opened.|
1517
1518**Error codes**
1519
1520For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1521
1522| ID| Error Message|
1523| -------- | ---------------------------------------- |
1524| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1525| 13900012     | Permission denied.         |
1526| 13900020     | Invalid argument.         |
1527| 14000011       | System inner fail.         |
1528
1529**Example**
1530
1531```ts
1532async function example() {
1533  console.info('getReadOnlyFdDemo');
1534  try {
1535    // Ensure that there are images and video files in the device.
1536    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1537    let fetchOptions: photoAccessHelper.FetchOptions = {
1538      fetchColumns: [],
1539      predicates: predicates
1540    };
1541    let assetResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1542    let photoAsset: photoAccessHelper.PhotoAsset = await assetResult.getFirstObject();
1543    let fd: number = await photoAsset.getReadOnlyFd();
1544    if (fd !== undefined) {
1545      console.info('File fd' + fd);
1546      photoAsset.close(fd);
1547    } else {
1548      console.error('getReadOnlyFd fail');
1549    }
1550  } catch (err) {
1551    console.error(`getReadOnlyFd demo err: ${err.code}, ${err.message}`);
1552  }
1553}
1554```
1555
1556### close<sup>(deprecated)</sup>
1557
1558close(fd: number, callback: AsyncCallback&lt;void&gt;): void
1559
1560Closes a file. This API uses an asynchronous callback to return the result.
1561
1562> **NOTE**
1563>
1564> 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, and the corresponding **close** API is also deprecated.
1565
1566**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1567
1568**Parameters**
1569
1570| Name     | Type                       | Mandatory  | Description   |
1571| -------- | ------------------------- | ---- | ----- |
1572| fd       | number                    | Yes   | FD of the file to close.|
1573| callback | AsyncCallback&lt;void&gt; | Yes   | Callback that returns no value.|
1574
1575**Error codes**
1576
1577For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1578
1579| ID| Error Message|
1580| -------- | ---------------------------------------- |
1581| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1582| 13900020     | Invalid argument.         |
1583| 14000011       | System inner fail.         |
1584
1585**Example**
1586
1587```ts
1588import { dataSharePredicates } from '@kit.ArkData';
1589
1590async function example() {
1591  console.info('closeDemo');
1592  try {
1593    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1594    let fetchOption: photoAccessHelper.FetchOptions = {
1595      fetchColumns: [],
1596      predicates: predicates
1597    };
1598    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1599    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1600    let fd: number = await photoAsset.open('rw');
1601    console.info('file fd', fd);
1602    photoAsset.close(fd, (err) => {
1603      if (err === undefined) {
1604        console.info('asset close succeed.');
1605      } else {
1606        console.error(`close failed, error: ${err.code}, ${err.message}`);
1607      }
1608    });
1609  } catch (err) {
1610    console.error(`close failed, error: ${err.code}, ${err.message}`);
1611  }
1612}
1613```
1614
1615### close<sup>(deprecated)</sup>
1616
1617close(fd: number): Promise&lt;void&gt;
1618
1619Closes a file. This API uses a promise to return the result.
1620
1621> **NOTE**
1622>
1623> 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, and the corresponding **close** API is also deprecated.
1624
1625**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1626
1627**Parameters**
1628
1629| Name | Type    | Mandatory  | Description   |
1630| ---- | ------ | ---- | ----- |
1631| fd   | number | Yes   | FD of the file to close.|
1632
1633**Return value**
1634
1635| Type                 | Description        |
1636| ------------------- | ---------- |
1637| Promise&lt;void&gt; | Promise that returns no value.|
1638
1639**Error codes**
1640
1641For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1642
1643| ID| Error Message|
1644| -------- | ---------------------------------------- |
1645| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1646| 13900020     | Invalid argument.         |
1647| 14000011       | System inner fail.         |
1648
1649**Example**
1650
1651```ts
1652import { dataSharePredicates } from '@kit.ArkData';
1653
1654async function example() {
1655  console.info('closeDemo');
1656  try {
1657    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1658    let fetchOption: photoAccessHelper.FetchOptions = {
1659      fetchColumns: [],
1660      predicates: predicates
1661    };
1662    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1663    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1664    let fd = await asset.open('rw');
1665    console.info('file fd', fd);
1666    await asset.close(fd);
1667    console.info('asset close succeed.');
1668  } catch (err) {
1669    console.error(`close failed, error: ${err.code}, ${err.message}`);
1670  }
1671}
1672```
1673
1674### getThumbnail
1675
1676getThumbnail(callback: AsyncCallback&lt;image.PixelMap&gt;): void
1677
1678Obtains the thumbnail of this file. This API uses an asynchronous callback to return the result.
1679
1680**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1681
1682**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1683
1684**Parameters**
1685
1686| Name     | Type                                 | Mandatory  | Description              |
1687| -------- | ----------------------------------- | ---- | ---------------- |
1688| callback | AsyncCallback&lt;[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)&gt; | Yes   | Callback used to return the PixelMap of the thumbnail.|
1689
1690**Error codes**
1691
1692For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1693
1694| ID| Error Message|
1695| -------- | ---------------------------------------- |
1696| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1697| 13900012     | Permission denied.         |
1698| 13900020     | Invalid argument.         |
1699| 14000011       | System inner fail.         |
1700
1701**Example**
1702
1703```ts
1704import { dataSharePredicates } from '@kit.ArkData';
1705
1706async function example() {
1707  console.info('getThumbnailDemo');
1708  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1709  let fetchOption: photoAccessHelper.FetchOptions = {
1710    fetchColumns: [],
1711    predicates: predicates
1712  };
1713  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1714  let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1715  console.info('asset displayName = ', asset.displayName);
1716  asset.getThumbnail((err, pixelMap) => {
1717    if (err === undefined) {
1718      console.info('getThumbnail successful ' + pixelMap);
1719    } else {
1720      console.error(`getThumbnail fail with error: ${err.code}, ${err.message}`);
1721    }
1722  });
1723}
1724```
1725
1726### getThumbnail
1727
1728getThumbnail(size: image.Size, callback: AsyncCallback&lt;image.PixelMap&gt;): void
1729
1730Obtains the file thumbnail of the given size. This API uses an asynchronous callback to return the result.
1731
1732**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1733
1734**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1735
1736**Parameters**
1737
1738| Name     | Type                                 | Mandatory  | Description              |
1739| -------- | ----------------------------------- | ---- | ---------------- |
1740| size     | [image.Size](../apis-image-kit/js-apis-image.md#size) | Yes   | Size of the thumbnail.           |
1741| callback | AsyncCallback&lt;[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)&gt; | Yes   | Callback used to return the PixelMap of the thumbnail.|
1742
1743**Error codes**
1744
1745For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1746
1747| ID| Error Message|
1748| -------- | ---------------------------------------- |
1749| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1750| 13900012     | Permission denied.         |
1751| 13900020     | Invalid argument.         |
1752| 14000011       | System inner fail.         |
1753
1754**Example**
1755
1756```ts
1757import { dataSharePredicates } from '@kit.ArkData';
1758import { image } from '@kit.ImageKit';
1759
1760async function example() {
1761  console.info('getThumbnailDemo');
1762  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1763  let fetchOption: photoAccessHelper.FetchOptions = {
1764    fetchColumns: [],
1765    predicates: predicates
1766  };
1767  let size: image.Size = { width: 720, height: 720 };
1768  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1769  let asset = await fetchResult.getFirstObject();
1770  console.info('asset displayName = ', asset.displayName);
1771  asset.getThumbnail(size, (err, pixelMap) => {
1772    if (err === undefined) {
1773      console.info('getThumbnail successful ' + pixelMap);
1774    } else {
1775      console.error(`getThumbnail fail with error: ${err.code}, ${err.message}`);
1776    }
1777  });
1778}
1779```
1780
1781### getThumbnail
1782
1783getThumbnail(size?: image.Size): Promise&lt;image.PixelMap&gt;
1784
1785Obtains the file thumbnail of the given size. This API uses a promise to return the result.
1786
1787**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1788
1789**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1790
1791**Parameters**
1792
1793| Name | Type            | Mandatory  | Description   |
1794| ---- | -------------- | ---- | ----- |
1795| size | [image.Size](../apis-image-kit/js-apis-image.md#size) | No   | Size of the thumbnail.|
1796
1797**Return value**
1798
1799| Type                           | Description                   |
1800| ----------------------------- | --------------------- |
1801| Promise&lt;[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)&gt; | Promise used to return the PixelMap of the thumbnail.|
1802
1803**Error codes**
1804
1805For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1806
1807| ID| Error Message|
1808| -------- | ---------------------------------------- |
1809| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1810| 13900012     | Permission denied.         |
1811| 13900020     | Invalid argument.         |
1812| 14000011       | System inner fail.         |
1813
1814**Example**
1815
1816```ts
1817import { dataSharePredicates } from '@kit.ArkData';
1818import { image } from '@kit.ImageKit';
1819import { BusinessError } from '@kit.BasicServicesKit';
1820
1821async function example() {
1822  console.info('getThumbnailDemo');
1823  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1824  let fetchOption: photoAccessHelper.FetchOptions = {
1825    fetchColumns: [],
1826    predicates: predicates
1827  };
1828  let size: image.Size = { width: 720, height: 720 };
1829  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1830  let asset = await fetchResult.getFirstObject();
1831  console.info('asset displayName = ', asset.displayName);
1832  asset.getThumbnail(size).then((pixelMap) => {
1833    console.info('getThumbnail successful ' + pixelMap);
1834  }).catch((err: BusinessError) => {
1835    console.error(`getThumbnail fail with error: ${err.code}, ${err.message}`);
1836  });
1837}
1838```
1839
1840### clone<sup>14+</sup>
1841
1842clone(title: string): Promise&lt;PhotoAsset&gt;
1843
1844Clones a media asset. The file name can be set, but the file type cannot be changed.
1845
1846**Required permissions**: ohos.permission.WRITE\_IMAGEVIDEO
1847
1848**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1849
1850**Parameters**
1851
1852| Name       | Type     | Mandatory  | Description                                |
1853| ---------- | ------- | ---- | ---------------------------------- |
1854| title| string | Yes   | Title of the cloned asset. The title must meet the following requirements:<br>- It does not contain a file name extension.<br>- The file name, which is in the format of title+file name extension, does not exceed 255 characters.<br>- The title does not contain any of the following characters:\ / : * ? " ' ` < > \| { } [ ] |
1855
1856**Return value**
1857
1858| Type               | Description                   |
1859| ------------------- | ----------------------- |
1860| Promise&lt;PhotoAsset&gt; | Promise used to return the [PhotoAsset](#photoasset) cloned.|
1861
1862**Error codes**
1863
1864For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1865
1866| ID   | Error Message                             |
1867| :------- | :-------------------------------- |
1868| 201 | Permission denied. |
1869| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1870| 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. |
1871
1872**Example**
1873
1874```ts
1875import { dataSharePredicates } from '@kit.ArkData';
1876import { systemDateTime } from '@kit.BasicServicesKit';
1877
1878async function example() {
1879  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1880  let fetchOptions: photoAccessHelper.FetchOptions = {
1881    fetchColumns: [],
1882    predicates: predicates
1883  };
1884  try {
1885    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1886    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1887    let title: string = systemDateTime.getTime().toString();
1888    let newAsset: photoAccessHelper.PhotoAsset = await photoAsset.clone(title);
1889    console.info('get new asset successfully');
1890  } catch (error) {
1891    console.error(`failed to get new asset. message =  ${error.code}, ${error.message}`);
1892  }
1893}
1894```
1895
1896## PhotoViewPicker
1897
1898Provides APIs for the user to select images and videos. Before using the APIs of **PhotoViewPicker**, you need to create a **PhotoViewPicker** instance.
1899
1900**Atomic service API**: This API can be used in atomic services since API version 11.
1901
1902**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1903
1904**Example**
1905
1906```ts
1907let photoPicker = new photoAccessHelper.PhotoViewPicker();
1908```
1909
1910### select
1911
1912select(option?: PhotoSelectOptions) : Promise&lt;PhotoSelectResult&gt;
1913
1914Starts a **photoPicker** page for the user to select one or more images or videos. This API uses a promise to return the result. You can pass in **PhotoSelectOptions** to specify the media file type and the maximum number of files to select.
1915
1916**NOTE**<br>The **photoUris** in the **PhotoSelectResult** object returned by this API has permanent authorization and can be used only by calling [photoAccessHelper.getAssets()](#getassets). For details, see [Using a Media File URI](../../file-management/user-file-uri-intro.md#using-a-media-file-uri).
1917
1918**Atomic service API**: This API can be used in atomic services since API version 11.
1919
1920**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1921
1922**Parameters**
1923
1924| Name | Type   | Mandatory| Description                      |
1925| ------- | ------- | ---- | -------------------------- |
1926| option | [PhotoSelectOptions](#photoselectoptions) | No  | Options for selecting files. If this parameter is not specified, up to 50 images and videos are selected by default.|
1927
1928**Return value**
1929
1930| Type                           | Description   |
1931| ----------------------------- | :---- |
1932| Promise&lt;[PhotoSelectResult](#photoselectresult)&gt; | Promise return information about the images or videos selected.|
1933
1934**Error codes**
1935
1936For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1937
1938| ID| Error Message|
1939| -------- | ---------------------------------------- |
1940| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1941| 13900042      | Unknown error.         |
1942
1943**Example**
1944
1945```ts
1946import { BusinessError } from '@kit.BasicServicesKit';
1947async function example01() {
1948  try {
1949    let PhotoSelectOptions = new photoAccessHelper.PhotoSelectOptions();
1950    PhotoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE;
1951    PhotoSelectOptions.maxSelectNumber = 5;
1952    let photoPicker = new photoAccessHelper.PhotoViewPicker();
1953    photoPicker.select(PhotoSelectOptions).then((PhotoSelectResult: photoAccessHelper.PhotoSelectResult) => {
1954      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
1955    }).catch((err: BusinessError) => {
1956      console.error(`PhotoViewPicker.select failed with err: ${err.code}, ${err.message}`);
1957    });
1958  } catch (error) {
1959    let err: BusinessError = error as BusinessError;
1960    console.error(`PhotoViewPicker failed with err: ${err.code}, ${err.message}`);
1961  }
1962}
1963```
1964
1965### select
1966
1967select(option: PhotoSelectOptions, callback: AsyncCallback&lt;PhotoSelectResult&gt;) : void
1968
1969Starts a **photoPicker** page for the user to select one or more images or videos. This API uses an asynchronous callback to return the result. You can pass in **PhotoSelectOptions** to specify the media file type and the maximum number of files to select.
1970
1971**NOTE**<br>The **photoUris** in the **PhotoSelectResult** object returned by this API has permanent authorization and can be used only by calling [photoAccessHelper.getAssets()](#getassets). For details, see [Using a Media File URI](../../file-management/user-file-uri-intro.md#using-a-media-file-uri).
1972
1973**Atomic service API**: This API can be used in atomic services since API version 11.
1974
1975**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1976
1977**Parameters**
1978
1979| Name | Type   | Mandatory| Description                      |
1980| ------- | ------- | ---- | -------------------------- |
1981| option | [PhotoSelectOptions](#photoselectoptions) | Yes  | Options for selecting images or videos.|
1982| callback | AsyncCallback&lt;[PhotoSelectResult](#photoselectresult)&gt;      | Yes  | Callback used to return information about the images or videos selected.|
1983
1984**Error codes**
1985
1986For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1987
1988| ID| Error Message|
1989| -------- | ---------------------------------------- |
1990| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1991| 13900042      | Unknown error.         |
1992
1993**Example**
1994
1995```ts
1996import { BusinessError } from '@kit.BasicServicesKit';
1997async function example02() {
1998  try {
1999    let PhotoSelectOptions = new photoAccessHelper.PhotoSelectOptions();
2000    PhotoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE;
2001    PhotoSelectOptions.maxSelectNumber = 5;
2002    let photoPicker = new photoAccessHelper.PhotoViewPicker();
2003    photoPicker.select(PhotoSelectOptions, (err: BusinessError, PhotoSelectResult: photoAccessHelper.PhotoSelectResult) => {
2004      if (err) {
2005        console.error(`PhotoViewPicker.select failed with err: ${err.code}, ${err.message}`);
2006        return;
2007      }
2008      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
2009    });
2010  } catch (error) {
2011    let err: BusinessError = error as BusinessError;
2012    console.error(`PhotoViewPicker failed with err: ${err.code}, ${err.message}`);
2013  }
2014}
2015```
2016
2017### select
2018
2019select(callback: AsyncCallback&lt;PhotoSelectResult&gt;) : void
2020
2021Starts a **photoPicker** page for the user to select one or more images or videos. This API uses an asynchronous callback to return the result.
2022
2023**NOTE**<br>The **photoUris** in the **PhotoSelectResult** object returned by this API has permanent authorization and can be used only by calling [photoAccessHelper.getAssets()](#getassets). For details, see [Using a Media File URI](../../file-management/user-file-uri-intro.md#using-a-media-file-uri).
2024
2025**Atomic service API**: This API can be used in atomic services since API version 11.
2026
2027**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2028
2029**Parameters**
2030
2031| Name | Type   | Mandatory| Description                      |
2032| ------- | ------- | ---- | -------------------------- |
2033| callback | AsyncCallback&lt;[PhotoSelectResult](#photoselectresult)&gt;      | Yes  | Callback used to return information about the images or videos selected.|
2034
2035**Error codes**
2036
2037For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2038
2039| ID| Error Message|
2040| -------- | ---------------------------------------- |
2041| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2042| 13900042      | Unknown error.         |
2043
2044**Example**
2045
2046```ts
2047import { BusinessError } from '@kit.BasicServicesKit';
2048async function example03() {
2049  try {
2050    let photoPicker = new photoAccessHelper.PhotoViewPicker();
2051    photoPicker.select((err: BusinessError, PhotoSelectResult: photoAccessHelper.PhotoSelectResult) => {
2052      if (err) {
2053        console.error(`PhotoViewPicker.select failed with err: ${err.code}, ${err.message}`);
2054        return;
2055      }
2056      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
2057    });
2058  } catch (error) {
2059    let err: BusinessError = error as BusinessError;
2060    console.error(`PhotoViewPicker failed with err: ${err.code}, ${err.message}`);
2061  }
2062}
2063```
2064
2065## FetchResult
2066
2067Provides APIs to manage the file retrieval result.
2068
2069### getCount
2070
2071getCount(): number
2072
2073Obtains the total number of files in the result set.
2074
2075**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2076
2077**Return value**
2078
2079| Type    | Description      |
2080| ------ | -------- |
2081| number | Returns the total number of files obtained.|
2082
2083**Error codes**
2084
2085For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2086
2087| ID| Error Message|
2088| -------- | ---------------------------------------- |
2089| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2090| 13900020     | Invalid argument.         |
2091| 14000011       | System inner fail.         |
2092
2093**Example**
2094
2095```ts
2096import { dataSharePredicates } from '@kit.ArkData';
2097
2098async function example() {
2099  console.info('getCountDemo');
2100  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2101  let fetchOption: photoAccessHelper.FetchOptions = {
2102    fetchColumns: [],
2103    predicates: predicates
2104  };
2105  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2106  let fetchCount = fetchResult.getCount();
2107  console.info('fetchCount = ', fetchCount);
2108}
2109```
2110
2111### isAfterLast
2112
2113isAfterLast(): boolean
2114
2115Checks whether the cursor is in the last row of the result set.
2116
2117**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2118
2119**Return value**
2120
2121| Type     | Description                                |
2122| ------- | ---------------------------------- |
2123| boolean | Returns **true** if the cursor is in the last row of the result set; returns **false** otherwise.|
2124
2125**Error codes**
2126
2127For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2128
2129| ID| Error Message|
2130| -------- | ---------------------------------------- |
2131| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2132| 13900020     | Invalid argument.         |
2133| 14000011       | System inner fail.         |
2134
2135**Example**
2136
2137```ts
2138import { dataSharePredicates } from '@kit.ArkData';
2139
2140async function example() {
2141  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2142  let fetchOption: photoAccessHelper.FetchOptions = {
2143    fetchColumns: [],
2144    predicates: predicates
2145  };
2146  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2147  let fetchCount = fetchResult.getCount();
2148  console.info('count:' + fetchCount);
2149  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getLastObject();
2150  if (fetchResult.isAfterLast()) {
2151    console.info('photoAsset isAfterLast displayName = ', photoAsset.displayName);
2152  } else {
2153    console.info('photoAsset not isAfterLast.');
2154  }
2155}
2156```
2157
2158### close
2159
2160close(): void
2161
2162Closes this **FetchFileResult** instance to invalidate it. After this instance is released, the APIs in this instance cannot be invoked.
2163
2164**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2165
2166**Error codes**
2167
2168For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2169
2170| ID| Error Message|
2171| -------- | ---------------------------------------- |
2172| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2173| 13900020     | Invalid argument.         |
2174| 14000011       | System inner fail.         |
2175
2176**Example**
2177
2178```ts
2179import { dataSharePredicates } from '@kit.ArkData';
2180
2181async function example() {
2182  console.info('fetchResultCloseDemo');
2183  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2184  let fetchOption: photoAccessHelper.FetchOptions = {
2185    fetchColumns: [],
2186    predicates: predicates
2187  };
2188  try {
2189    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2190    fetchResult.close();
2191    console.info('close succeed.');
2192  } catch (err) {
2193    console.error(`close fail. error: ${err.code}, ${err.message}`);
2194  }
2195}
2196```
2197
2198### getFirstObject
2199
2200getFirstObject(callback: AsyncCallback&lt;T&gt;): void
2201
2202Obtains the first file asset in the result set. This API uses an asynchronous callback to return the result.
2203
2204**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2205
2206**Parameters**
2207
2208| Name  | Type                                         | Mandatory| Description                                       |
2209| -------- | --------------------------------------------- | ---- | ------------------------------------------- |
2210| callback | AsyncCallback&lt;T&gt; | Yes  | Callback used to return the first file asset obtained.|
2211
2212**Error codes**
2213
2214For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2215
2216| ID| Error Message|
2217| -------- | ---------------------------------------- |
2218| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2219| 13900020     | Invalid argument.         |
2220| 14000011       | System inner fail.         |
2221
2222**Example**
2223
2224```ts
2225import { dataSharePredicates } from '@kit.ArkData';
2226
2227async function example() {
2228  console.info('getFirstObjectDemo');
2229  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2230  let fetchOption: photoAccessHelper.FetchOptions = {
2231    fetchColumns: [],
2232    predicates: predicates
2233  };
2234  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2235  fetchResult.getFirstObject((err, photoAsset) => {
2236    if (photoAsset !== undefined) {
2237      console.info('photoAsset displayName: ', photoAsset.displayName);
2238    } else {
2239      console.error(`photoAsset failed with err:${err.code}, ${err.message}`);
2240    }
2241  });
2242}
2243```
2244
2245### getFirstObject
2246
2247getFirstObject(): Promise&lt;T&gt;
2248
2249Obtains the first file asset in the result set. This API uses a promise to return the result.
2250
2251**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2252
2253**Return value**
2254
2255| Type                                   | Description                      |
2256| --------------------------------------- | -------------------------- |
2257| Promise&lt;T&gt; | Promise used to return the first object in the result set.|
2258
2259**Error codes**
2260
2261For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2262
2263| ID| Error Message|
2264| -------- | ---------------------------------------- |
2265| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2266| 13900020     | Invalid argument.         |
2267| 14000011       | System inner fail.         |
2268
2269**Example**
2270
2271```ts
2272import { dataSharePredicates } from '@kit.ArkData';
2273
2274async function example() {
2275  console.info('getFirstObjectDemo');
2276  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2277  let fetchOption: photoAccessHelper.FetchOptions = {
2278    fetchColumns: [],
2279    predicates: predicates
2280  };
2281  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2282  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2283  console.info('photoAsset displayName: ', photoAsset.displayName);
2284}
2285```
2286
2287### getNextObject
2288
2289getNextObject(callback: AsyncCallback&lt;T&gt;): void
2290
2291Obtains the next file asset in the result set. This API uses an asynchronous callback to return the result.
2292Before using this API, you must use [isAfterLast()](#isafterlast) to check whether the current position is the end of the result set.
2293
2294**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2295
2296**Parameters**
2297
2298| Name   | Type                                         | Mandatory| Description                                     |
2299| --------- | --------------------------------------------- | ---- | ----------------------------------------- |
2300| callback | AsyncCallback&lt;T&gt; | Yes  | Callback used to return the next file asset.|
2301
2302**Error codes**
2303
2304For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2305
2306| ID| Error Message|
2307| -------- | ---------------------------------------- |
2308| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2309| 13900020     | Invalid argument.         |
2310| 14000011       | System inner fail.         |
2311
2312**Example**
2313
2314```ts
2315import { dataSharePredicates } from '@kit.ArkData';
2316
2317async function example() {
2318  console.info('getNextObjectDemo');
2319  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2320  let fetchOption: photoAccessHelper.FetchOptions = {
2321    fetchColumns: [],
2322    predicates: predicates
2323  };
2324  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2325  await fetchResult.getFirstObject();
2326  if (!fetchResult.isAfterLast()) {
2327    fetchResult.getNextObject((err, photoAsset) => {
2328      if (photoAsset !== undefined) {
2329        console.info('photoAsset displayName: ', photoAsset.displayName);
2330      } else {
2331        console.error(`photoAsset failed with err: ${err.code}, ${err.message}`);
2332      }
2333    });
2334  }
2335}
2336```
2337
2338### getNextObject
2339
2340getNextObject(): Promise&lt;T&gt;
2341
2342Obtains the next file asset in the result set. This API uses a promise to return the result.
2343Before using this API, you must use [isAfterLast()](#isafterlast) to check whether the current position is the end of the result set.
2344
2345**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2346
2347**Return value**
2348
2349| Type                                   | Description             |
2350| --------------------------------------- | ----------------- |
2351| Promise&lt;T&gt; | Promise used to return the next object in the result set.|
2352
2353**Error codes**
2354
2355For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2356
2357| ID| Error Message|
2358| -------- | ---------------------------------------- |
2359| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2360| 13900020     | Invalid argument.         |
2361| 14000011       | System inner fail.         |
2362
2363**Example**
2364
2365```ts
2366import { dataSharePredicates } from '@kit.ArkData';
2367
2368async function example() {
2369  console.info('getNextObjectDemo');
2370  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2371  let fetchOption: photoAccessHelper.FetchOptions = {
2372    fetchColumns: [],
2373    predicates: predicates
2374  };
2375  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2376  await fetchResult.getFirstObject();
2377  if (!fetchResult.isAfterLast()) {
2378    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getNextObject();
2379    console.info('photoAsset displayName: ', photoAsset.displayName);
2380  }
2381}
2382```
2383
2384### getLastObject
2385
2386getLastObject(callback: AsyncCallback&lt;T&gt;): void
2387
2388Obtains the last file asset in the result set. This API uses an asynchronous callback to return the result.
2389
2390**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2391
2392**Parameters**
2393
2394| Name  | Type                                         | Mandatory| Description                       |
2395| -------- | --------------------------------------------- | ---- | --------------------------- |
2396| callback | AsyncCallback&lt;T&gt; | Yes  | Callback used to return the last file asset obtained.|
2397
2398**Error codes**
2399
2400For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2401
2402| ID| Error Message|
2403| -------- | ---------------------------------------- |
2404| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2405| 13900020     | Invalid argument.         |
2406| 14000011       | System inner fail.         |
2407
2408**Example**
2409
2410```ts
2411import { dataSharePredicates } from '@kit.ArkData';
2412
2413async function example() {
2414  console.info('getLastObjectDemo');
2415  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2416  let fetchOption: photoAccessHelper.FetchOptions = {
2417    fetchColumns: [],
2418    predicates: predicates
2419  };
2420  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2421  fetchResult.getLastObject((err, photoAsset) => {
2422    if (photoAsset !== undefined) {
2423      console.info('photoAsset displayName: ', photoAsset.displayName);
2424    } else {
2425      console.error(`photoAsset failed with err: ${err.code}, ${err.message}`);
2426    }
2427  });
2428}
2429```
2430
2431### getLastObject
2432
2433getLastObject(): Promise&lt;T&gt;
2434
2435Obtains the last file asset in the result set. This API uses a promise to return the result.
2436
2437**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2438
2439**Return value**
2440
2441| Type                                   | Description             |
2442| --------------------------------------- | ----------------- |
2443| Promise&lt;T&gt; | Promise used to return the last object in the result set.|
2444
2445**Error codes**
2446
2447For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2448
2449| ID| Error Message|
2450| -------- | ---------------------------------------- |
2451| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2452| 13900020     | Invalid argument.         |
2453| 14000011       | System inner fail.         |
2454
2455**Example**
2456
2457```ts
2458import { dataSharePredicates } from '@kit.ArkData';
2459
2460async function example() {
2461  console.info('getLastObjectDemo');
2462  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2463  let fetchOption: photoAccessHelper.FetchOptions = {
2464    fetchColumns: [],
2465    predicates: predicates
2466  };
2467  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2468  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getLastObject();
2469  console.info('photoAsset displayName: ', photoAsset.displayName);
2470}
2471```
2472
2473### getObjectByPosition
2474
2475getObjectByPosition(index: number, callback: AsyncCallback&lt;T&gt;): void
2476
2477Obtains a file asset with the specified index in the result set. This API uses an asynchronous callback to return the result.
2478
2479**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2480
2481**Parameters**
2482
2483| Name      | Type                                      | Mandatory  | Description                |
2484| -------- | ---------------------------------------- | ---- | ------------------ |
2485| index    | number                                   | Yes   | Index of the file asset to obtain. The value starts from **0**.    |
2486| callback | AsyncCallback&lt;T&gt; | Yes   | Callback used to return the file asset obtained.|
2487
2488**Error codes**
2489
2490For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2491
2492| ID| Error Message|
2493| -------- | ---------------------------------------- |
2494| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2495| 13900020     | Invalid argument.         |
2496| 14000011       | System inner fail.         |
2497
2498**Example**
2499
2500```ts
2501import { dataSharePredicates } from '@kit.ArkData';
2502
2503async function example() {
2504  console.info('getObjectByPositionDemo');
2505  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2506  let fetchOption: photoAccessHelper.FetchOptions = {
2507    fetchColumns: [],
2508    predicates: predicates
2509  };
2510  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2511  fetchResult.getObjectByPosition(0, (err, photoAsset) => {
2512    if (photoAsset !== undefined) {
2513      console.info('photoAsset displayName: ', photoAsset.displayName);
2514    } else {
2515      console.error(`photoAsset failed with err: ${err.code}, ${err.message}`);
2516    }
2517  });
2518}
2519```
2520
2521### getObjectByPosition
2522
2523getObjectByPosition(index: number): Promise&lt;T&gt;
2524
2525Obtains a file asset with the specified index in the result set. This API uses a promise to return the result.
2526
2527**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2528
2529**Parameters**
2530
2531| Name   | Type    | Mandatory  | Description            |
2532| ----- | ------ | ---- | -------------- |
2533| index | number | Yes   | Index of the file asset to obtain. The value starts from **0**.|
2534
2535**Return value**
2536
2537| Type                                   | Description             |
2538| --------------------------------------- | ----------------- |
2539| Promise&lt;T&gt; | Promise used to return the file asset obtained.|
2540
2541**Error codes**
2542
2543For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2544
2545| ID| Error Message|
2546| -------- | ---------------------------------------- |
2547| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2548| 13900020     | Invalid argument.         |
2549| 14000011       | System inner fail.         |
2550
2551**Example**
2552
2553```ts
2554import { dataSharePredicates } from '@kit.ArkData';
2555
2556async function example() {
2557  console.info('getObjectByPositionDemo');
2558  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2559  let fetchOption: photoAccessHelper.FetchOptions = {
2560    fetchColumns: [],
2561    predicates: predicates
2562  };
2563  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2564  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getObjectByPosition(0);
2565  console.info('photoAsset displayName: ', photoAsset.displayName);
2566}
2567```
2568
2569### getAllObjects
2570
2571getAllObjects(callback: AsyncCallback&lt;Array&lt;T&gt;&gt;): void
2572
2573Obtains all the file assets in the result set. This API uses an asynchronous callback to return the result.
2574
2575**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2576
2577**Parameters**
2578
2579| Name  | Type                                         | Mandatory| Description                                       |
2580| -------- | --------------------------------------------- | ---- | ------------------------------------------- |
2581| callback | AsyncCallback&lt;Array&lt;T&gt;&gt; | Yes  | Callback used to return an array of all file assets in the result set.|
2582
2583**Error codes**
2584
2585For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2586
2587| ID| Error Message|
2588| -------- | ---------------------------------------- |
2589| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2590| 13900020     | Invalid argument.         |
2591| 14000011       | System inner fail.         |
2592
2593**Example**
2594
2595```ts
2596import { dataSharePredicates } from '@kit.ArkData';
2597
2598async function example() {
2599  console.info('getAllObjectDemo');
2600  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2601  let fetchOption: photoAccessHelper.FetchOptions = {
2602    fetchColumns: [],
2603    predicates: predicates
2604  };
2605  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2606  fetchResult.getAllObjects((err, photoAssetList) => {
2607    if (photoAssetList !== undefined) {
2608      console.info('photoAssetList length: ', photoAssetList.length);
2609    } else {
2610      console.error(`photoAssetList failed with err:${err.code}, ${err.message}`);
2611    }
2612  });
2613}
2614```
2615
2616### getAllObjects
2617
2618getAllObjects(): Promise&lt;Array&lt;T&gt;&gt;
2619
2620Obtains all the file assets in the result set. This API uses a promise to return the result.
2621
2622**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2623
2624**Return value**
2625
2626| Type                                   | Description                      |
2627| --------------------------------------- | -------------------------- |
2628| Promise&lt;Array&lt;T&gt;&gt; | Promise used to return an array of all file assets in the result set.|
2629
2630**Error codes**
2631
2632For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2633
2634| ID| Error Message|
2635| -------- | ---------------------------------------- |
2636| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2637| 13900020     | Invalid argument.         |
2638| 14000011       | System inner fail.         |
2639
2640**Example**
2641
2642```ts
2643import { dataSharePredicates } from '@kit.ArkData';
2644
2645async function example() {
2646  console.info('getAllObjectDemo');
2647  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2648  let fetchOption: photoAccessHelper.FetchOptions = {
2649    fetchColumns: [],
2650    predicates: predicates
2651  };
2652  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2653  let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects();
2654  console.info('photoAssetList length: ', photoAssetList.length);
2655}
2656```
2657
2658## Album
2659
2660Provides APIs to manage albums.
2661
2662### Properties
2663
2664**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2665
2666| Name          | Type   | Readable  | Writable | Description  |
2667| ------------ | ------ | ---- | ---- | ------- |
2668| albumType | [AlbumType](#albumtype) | Yes   | No   | Type of the album.   |
2669| albumSubtype | [AlbumSubtype](#albumsubtype) | Yes   | No  | Subtype of the album.   |
2670| albumName | string | Yes   | Yes for a user album; no for a system album.  | Name of the album.   |
2671| albumUri | string | Yes   | No   | URI of the album.  |
2672| count | number | Yes   | No   |  Number of files in the album.|
2673| coverUri | string | Yes   | No   | URI of the cover file of the album.|
2674| imageCount<sup>11+</sup> | number | Yes  | No  | Number of images in the album.|
2675| videoCount<sup>11+</sup> | number | Yes  | No  | Number of videos in the album.|
2676
2677### getAssets
2678
2679getAssets(options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;PhotoAsset&gt;&gt;): void
2680
2681Obtains image and video assets. This API uses an asynchronous callback to return the result.
2682
2683**Required permissions**: ohos.permission.READ_IMAGEVIDEO
2684
2685**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2686
2687**Parameters**
2688
2689| Name  | Type                     | Mandatory| Description      |
2690| -------- | ------------------------- | ---- | ---------- |
2691| options | [FetchOptions](#fetchoptions) | Yes  | Options for fetching the assets.|
2692| callback | AsyncCallback&lt;[FetchResult](#fetchresult)&lt;[PhotoAsset](#photoasset)&gt;&gt; | Yes  | Callback used to return the image and video assets obtained.|
2693
2694**Error codes**
2695
2696For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2697
2698| ID| Error Message|
2699| -------- | ---------------------------------------- |
2700| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2701| 13900012     | Permission denied.         |
2702| 13900020     | Invalid argument.         |
2703| 14000011       | System inner fail.         |
2704
2705**Example**
2706
2707```ts
2708import { dataSharePredicates } from '@kit.ArkData';
2709
2710async function example() {
2711  console.info('albumGetAssetsDemoCallback');
2712  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2713  let albumFetchOptions: photoAccessHelper.FetchOptions = {
2714    fetchColumns: [],
2715    predicates: predicates
2716  };
2717  let fetchOption: photoAccessHelper.FetchOptions = {
2718    fetchColumns: [],
2719    predicates: predicates
2720  };
2721  let albumList: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
2722  let album: photoAccessHelper.Album = await albumList.getFirstObject();
2723  album.getAssets(fetchOption, (err, albumFetchResult) => {
2724    if (albumFetchResult !== undefined) {
2725      console.info('album getAssets successfully, getCount: ' + albumFetchResult.getCount());
2726    } else {
2727      console.error(`album getAssets failed with error: ${err.code}, ${err.message}`);
2728    }
2729  });
2730}
2731```
2732
2733### getAssets
2734
2735getAssets(options: FetchOptions): Promise&lt;FetchResult&lt;PhotoAsset&gt;&gt;
2736
2737Obtains image and video assets. This API uses a promise to return the result.
2738
2739**Required permissions**: ohos.permission.READ_IMAGEVIDEO
2740
2741**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2742
2743**Parameters**
2744
2745| Name  | Type                     | Mandatory| Description      |
2746| -------- | ------------------------- | ---- | ---------- |
2747| options | [FetchOptions](#fetchoptions) | Yes  | Options for fetching the assets.|
2748
2749**Return value**
2750
2751| Type                                   | Description             |
2752| --------------------------------------- | ----------------- |
2753| Promise&lt;[FetchResult](#fetchresult)&lt;[PhotoAsset](#photoasset)&gt;&gt; | Promise used to return the image and video assets obtained.|
2754
2755**Error codes**
2756
2757For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2758
2759| ID| Error Message|
2760| -------- | ---------------------------------------- |
2761| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2762| 13900012     | Permission denied.         |
2763| 13900020     | Invalid argument.         |
2764| 14000011       | System inner fail.         |
2765
2766**Example**
2767
2768```ts
2769import { dataSharePredicates } from '@kit.ArkData';
2770import { BusinessError } from '@kit.BasicServicesKit';
2771
2772async function example() {
2773  console.info('albumGetAssetsDemoPromise');
2774  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2775  let albumFetchOptions: photoAccessHelper.FetchOptions = {
2776    fetchColumns: [],
2777    predicates: predicates
2778  };
2779  let fetchOption: photoAccessHelper.FetchOptions = {
2780    fetchColumns: [],
2781    predicates: predicates
2782  };
2783  let albumList: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
2784  let album: photoAccessHelper.Album = await albumList.getFirstObject();
2785  album.getAssets(fetchOption).then((albumFetchResult) => {
2786    console.info('album getAssets successfully, getCount: ' + albumFetchResult.getCount());
2787  }).catch((err: BusinessError) => {
2788    console.error(`album getAssets failed with error: ${err.code}, ${err.message}`);
2789  });
2790}
2791```
2792
2793### commitModify
2794
2795commitModify(callback: AsyncCallback&lt;void&gt;): void
2796
2797Commits the modification on the album attributes to the database. This API uses an asynchronous callback to return the result.
2798
2799**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
2800
2801**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2802
2803**Parameters**
2804
2805| Name  | Type                     | Mandatory| Description      |
2806| -------- | ------------------------- | ---- | ---------- |
2807| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
2808
2809**Error codes**
2810
2811For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2812
2813| ID| Error Message|
2814| -------- | ---------------------------------------- |
2815| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2816| 13900012     | Permission denied.         |
2817| 13900020     | Invalid argument.         |
2818| 14000011       | System inner fail.         |
2819
2820**Example**
2821
2822```ts
2823import { dataSharePredicates } from '@kit.ArkData';
2824
2825async function example() {
2826  console.info('albumCommitModifyDemo');
2827  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2828  let albumFetchOptions: photoAccessHelper.FetchOptions = {
2829    fetchColumns: [],
2830    predicates: predicates
2831  };
2832  let albumList: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
2833  let album: photoAccessHelper.Album = await albumList.getFirstObject();
2834  album.albumName = 'hello';
2835  album.commitModify((err) => {
2836    if (err !== undefined) {
2837      console.error(`commitModify failed with error: ${err.code}, ${err.message}`);
2838    } else {
2839      console.info('commitModify successfully');
2840    }
2841  });
2842}
2843```
2844
2845### commitModify
2846
2847commitModify(): Promise&lt;void&gt;
2848
2849Commits the modification on the album attributes to the database. This API uses a promise to return the result.
2850
2851**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
2852
2853**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2854
2855**Return value**
2856
2857| Type                 | Description          |
2858| ------------------- | ------------ |
2859| Promise&lt;void&gt; | Promise that returns no value.|
2860
2861**Error codes**
2862
2863For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2864
2865| ID| Error Message|
2866| -------- | ---------------------------------------- |
2867| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2868| 13900012     | Permission denied.         |
2869| 13900020     | Invalid argument.         |
2870| 14000011       | System inner fail.         |
2871
2872**Example**
2873
2874```ts
2875import { dataSharePredicates } from '@kit.ArkData';
2876import { BusinessError } from '@kit.BasicServicesKit';
2877
2878async function example() {
2879  console.info('albumCommitModifyDemo');
2880  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2881  let albumFetchOptions: photoAccessHelper.FetchOptions = {
2882    fetchColumns: [],
2883    predicates: predicates
2884  };
2885  let albumList: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
2886  let album: photoAccessHelper.Album = await albumList.getFirstObject();
2887  album.albumName = 'hello';
2888  album.commitModify().then(() => {
2889    console.info('commitModify successfully');
2890  }).catch((err: BusinessError) => {
2891    console.error(`commitModify failed with error: ${err.code}, ${err.message}`);
2892  });
2893}
2894```
2895
2896### addAssets<sup>(deprecated)</sup>
2897
2898addAssets(assets: Array&lt;PhotoAsset&gt;, callback: AsyncCallback&lt;void&gt;): void
2899
2900Adds image and video assets to an album. Before the operation, ensure that the image and video assets to add and the album exist. This API uses an asynchronous callback to return the result.
2901
2902> **NOTE**
2903>
2904> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.addAssets](#addassets11) instead.
2905
2906**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
2907
2908**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2909
2910**Parameters**
2911
2912| Name  | Type                     | Mandatory| Description      |
2913| -------- | ------------------------- | ---- | ---------- |
2914| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Array of the image and video assets to add.|
2915| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
2916
2917**Error codes**
2918
2919For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2920
2921| ID| Error Message|
2922| -------- | ---------------------------------------- |
2923| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2924| 13900012     | Permission denied.         |
2925| 13900020     | Invalid argument.         |
2926| 14000011       | System inner fail.         |
2927
2928**Example**
2929
2930```ts
2931import { dataSharePredicates } from '@kit.ArkData';
2932
2933async function example() {
2934  try {
2935    console.info('addAssetsDemoCallback');
2936    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2937    let fetchOption: photoAccessHelper.FetchOptions = {
2938      fetchColumns: [],
2939      predicates: predicates
2940    };
2941    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
2942    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
2943    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2944    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2945    album.addAssets([asset], (err) => {
2946      if (err === undefined) {
2947        console.info('album addAssets successfully');
2948      } else {
2949        console.error(`album addAssets failed with error: ${err.code}, ${err.message}`);
2950      }
2951    });
2952  } catch (err) {
2953    console.error(`addAssetsDemoCallback failed with error: ${err.code}, ${err.message}`);
2954  }
2955}
2956```
2957
2958### addAssets<sup>(deprecated)</sup>
2959
2960addAssets(assets: Array&lt;PhotoAsset&gt;): Promise&lt;void&gt;
2961
2962Adds image and video assets to an album. Before the operation, ensure that the image and video assets to add and the album exist. This API uses a promise to return the result.
2963
2964> **NOTE**
2965>
2966> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.addAssets](#addassets11) instead.
2967
2968**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
2969
2970**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2971
2972**Parameters**
2973
2974| Name  | Type                     | Mandatory| Description      |
2975| -------- | ------------------------- | ---- | ---------- |
2976| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Array of the image and video assets to add.|
2977
2978**Return value**
2979
2980| Type                                   | Description             |
2981| --------------------------------------- | ----------------- |
2982|Promise&lt;void&gt; | Promise that returns no value.|
2983
2984**Error codes**
2985
2986For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2987
2988| ID| Error Message|
2989| -------- | ---------------------------------------- |
2990| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2991| 13900012     | Permission denied.         |
2992| 13900020     | Invalid argument.         |
2993| 14000011       | System inner fail.         |
2994
2995**Example**
2996
2997```ts
2998import { dataSharePredicates } from '@kit.ArkData';
2999import { BusinessError } from '@kit.BasicServicesKit';
3000
3001async function example() {
3002  try {
3003    console.info('addAssetsDemoPromise');
3004    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3005    let fetchOption: photoAccessHelper.FetchOptions = {
3006      fetchColumns: [],
3007      predicates: predicates
3008    };
3009    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
3010    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
3011    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
3012    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3013    album.addAssets([asset]).then(() => {
3014      console.info('album addAssets successfully');
3015    }).catch((err: BusinessError) => {
3016      console.error(`album addAssets failed with error: ${err.code}, ${err.message}`);
3017    });
3018  } catch (err) {
3019    console.error(`addAssetsDemoPromise failed with error: ${err.code}, ${err.message}`);
3020  }
3021}
3022```
3023
3024### removeAssets<sup>(deprecated)</sup>
3025
3026removeAssets(assets: Array&lt;PhotoAsset&gt;, callback: AsyncCallback&lt;void&gt;): void
3027
3028Removes image and video assets from an album. The album and file resources must exist. This API uses an asynchronous callback to return the result.
3029
3030> **NOTE**
3031>
3032> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.removeAssets](#removeassets11) instead.
3033
3034**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3035
3036**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3037
3038**Parameters**
3039
3040| Name  | Type                     | Mandatory| Description      |
3041| -------- | ------------------------- | ---- | ---------- |
3042| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Array of the image and video assets to remove.|
3043| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
3044
3045**Error codes**
3046
3047For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3048
3049| ID| Error Message|
3050| -------- | ---------------------------------------- |
3051| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3052| 13900012     | Permission denied.         |
3053| 13900020     | Invalid argument.         |
3054| 14000011       | System inner fail.         |
3055
3056**Example**
3057
3058```ts
3059import { dataSharePredicates } from '@kit.ArkData';
3060
3061async function example() {
3062  try {
3063    console.info('removeAssetsDemoCallback');
3064    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3065    let fetchOption: photoAccessHelper.FetchOptions = {
3066      fetchColumns: [],
3067      predicates: predicates
3068    };
3069    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
3070    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
3071    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
3072    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3073    album.removeAssets([asset], (err) => {
3074      if (err === undefined) {
3075        console.info('album removeAssets successfully');
3076      } else {
3077        console.error(`album removeAssets failed with error: ${err.code}, ${err.message}`);
3078      }
3079    });
3080  } catch (err) {
3081    console.error(`removeAssetsDemoCallback failed with error: ${err.code}, ${err.message}`);
3082  }
3083}
3084```
3085
3086### removeAssets<sup>(deprecated)</sup>
3087
3088removeAssets(assets: Array&lt;PhotoAsset&gt;): Promise&lt;void&gt;
3089
3090Removes image and video assets from an album. The album and file resources must exist. This API uses a promise to return the result.
3091
3092> **NOTE**
3093>
3094> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.removeAssets](#removeassets11) instead.
3095
3096**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3097
3098**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3099
3100**Parameters**
3101
3102| Name  | Type                     | Mandatory| Description      |
3103| -------- | ------------------------- | ---- | ---------- |
3104| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Array of the image and video assets to remove.|
3105
3106**Return value**
3107
3108| Type                                   | Description             |
3109| --------------------------------------- | ----------------- |
3110|Promise&lt;void&gt; | Promise that returns no value.|
3111
3112**Error codes**
3113
3114For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3115
3116| ID| Error Message|
3117| -------- | ---------------------------------------- |
3118| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3119| 13900012     | Permission denied.         |
3120| 13900020     | Invalid argument.         |
3121| 14000011       | System inner fail.         |
3122
3123**Example**
3124
3125```ts
3126import { dataSharePredicates } from '@kit.ArkData';
3127import { BusinessError } from '@kit.BasicServicesKit';
3128
3129async function example() {
3130  try {
3131    console.info('removeAssetsDemoPromise');
3132    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3133    let fetchOption: photoAccessHelper.FetchOptions = {
3134      fetchColumns: [],
3135      predicates: predicates
3136    };
3137    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
3138    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
3139    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
3140    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3141    album.removeAssets([asset]).then(() => {
3142      console.info('album removeAssets successfully');
3143    }).catch((err: BusinessError) => {
3144      console.error(`album removeAssets failed with error: ${err.code}, ${err.message}`);
3145    });
3146  } catch (err) {
3147    console.error(`removeAssetsDemoPromise failed with error: ${err.code}, ${err.message}`);
3148  }
3149}
3150```
3151
3152## MediaAssetChangeRequest<sup>11+</sup>
3153
3154Represents a media asset change request.
3155
3156**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3157
3158### constructor<sup>11+</sup>
3159
3160constructor(asset: PhotoAsset)
3161
3162Constructor.
3163
3164**Atomic service API**: This API can be used in atomic services since API version 12.
3165
3166**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3167
3168**Parameters**
3169
3170| Name  | Type                     | Mandatory| Description      |
3171| -------- | ------------------------- | ---- | ---------- |
3172| asset | [PhotoAsset](#photoasset) | Yes  | Assets to change.|
3173
3174**Error codes**
3175
3176For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3177
3178| ID| Error Message|
3179| -------- | ---------------------------------------- |
3180| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3181| 14000011       | System inner fail.          |
3182
3183**Example**
3184
3185```ts
3186import { dataSharePredicates } from '@kit.ArkData';
3187
3188async function example() {
3189  console.info('MediaAssetChangeRequest constructorDemo');
3190  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3191  let fetchOptions: photoAccessHelper.FetchOptions = {
3192    fetchColumns: [],
3193    predicates: predicates
3194  };
3195  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3196  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3197  let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(photoAsset);
3198}
3199```
3200
3201### createImageAssetRequest<sup>11+</sup>
3202
3203static createImageAssetRequest(context: Context, fileUri: string): MediaAssetChangeRequest
3204
3205Creates an image asset change request.
3206
3207Use **fileUri** to specify the data source of the asset to be created. For details, see [FileUri](../apis-core-file-kit/js-apis-file-fileuri.md).
3208
3209**Atomic service API**: This API can be used in atomic services since API version 12.
3210
3211**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3212
3213**Parameters**
3214
3215| Name | Type   | Mandatory| Description                      |
3216| ------- | ------- | ---- | -------------------------- |
3217| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
3218| fileUri | string | Yes  | Data source of the image asset, which is specified by a URI in the application sandbox directory. Example: **'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg'**.|
3219
3220**Return value**
3221
3222| Type                                   | Description             |
3223| --------------------------------------- | ----------------- |
3224| [MediaAssetChangeRequest](#mediaassetchangerequest11) | **MediaAssetChangeRequest** created.|
3225
3226**Error codes**
3227
3228For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3229
3230| ID| Error Message|
3231| -------- | ---------------------------------------- |
3232| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3233| 13900002   | No such file.         |
3234| 14000011   | System inner fail.        |
3235
3236**Example**
3237
3238```ts
3239async function example() {
3240  console.info('createImageAssetRequestDemo');
3241  try {
3242    // Ensure that the asset specified by fileUri exists.
3243    let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
3244    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createImageAssetRequest(context, fileUri);
3245    await phAccessHelper.applyChanges(assetChangeRequest);
3246    console.info('apply createImageAssetRequest successfully');
3247  } catch (err) {
3248    console.error(`createImageAssetRequestDemo failed with error: ${err.code}, ${err.message}`);
3249  }
3250}
3251```
3252
3253### createVideoAssetRequest<sup>11+</sup>
3254
3255static createVideoAssetRequest(context: Context, fileUri: string): MediaAssetChangeRequest
3256
3257Creates a video asset change request.
3258
3259Use **fileUri** to specify the data source of the asset to be created. For details, see [FileUri](../apis-core-file-kit/js-apis-file-fileuri.md).
3260
3261**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3262
3263**Parameters**
3264
3265| Name | Type   | Mandatory| Description                      |
3266| ------- | ------- | ---- | -------------------------- |
3267| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
3268| fileUri | string | Yes  | Data source of the video asset, which is specified by a URI in the application sandbox directory. Example: **'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.mp4'**.|
3269
3270**Return value**
3271
3272| Type                                   | Description             |
3273| --------------------------------------- | ----------------- |
3274| [MediaAssetChangeRequest](#mediaassetchangerequest11) | **MediaAssetChangeRequest** created.|
3275
3276**Error codes**
3277
3278For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3279
3280| ID| Error Message|
3281| -------- | ---------------------------------------- |
3282| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3283| 13900002   | No such file.         |
3284| 14000011   | System inner fail.        |
3285
3286**Example**
3287
3288```ts
3289async function example() {
3290  console.info('createVideoAssetRequestDemo');
3291  try {
3292    // Ensure that the asset specified by fileUri exists.
3293    let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.mp4';
3294    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createVideoAssetRequest(context, fileUri);
3295    await phAccessHelper.applyChanges(assetChangeRequest);
3296    console.info('apply createVideoAssetRequest successfully');
3297  } catch (err) {
3298    console.error(`createVideoAssetRequestDemo failed with error: ${err.code}, ${err.message}`);
3299  }
3300}
3301```
3302
3303### createAssetRequest<sup>11+</sup>
3304
3305static createAssetRequest(context: Context, photoType: PhotoType, extension: string, options?: CreateOptions): MediaAssetChangeRequest
3306
3307Create an asset change request based on the file type and filename extension.
3308
3309**Atomic service API**: This API can be used in atomic services since API version 11.
3310
3311**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3312
3313**Parameters**
3314
3315| Name | Type   | Mandatory| Description                      |
3316| ------- | ------- | ---- | -------------------------- |
3317| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
3318| photoType  | [PhotoType](#phototype)        | Yes  | Type of the file to create, which can be **IMAGE** or **VIDEO**.             |
3319| extension  | string        | Yes  | File name extension, for example, **'jpg'**.             |
3320| options  | [CreateOptions](#createoptions)        | No  | Options for creating the image or video asset, for example, **{title: 'testPhoto'}**.             |
3321
3322**Return value**
3323
3324| Type                                   | Description             |
3325| --------------------------------------- | ----------------- |
3326| [MediaAssetChangeRequest](#mediaassetchangerequest11) | **MediaAssetChangeRequest** created.|
3327
3328**Error codes**
3329
3330For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3331
3332| ID| Error Message|
3333| -------- | ---------------------------------------- |
3334| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3335| 14000011       | System inner fail.         |
3336
3337**Example**
3338
3339```ts
3340async function example() {
3341  console.info('createAssetRequestDemo');
3342  try {
3343    let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
3344    let extension: string = 'jpg';
3345    let options: photoAccessHelper.CreateOptions = {
3346      title: 'testPhoto'
3347    }
3348    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createAssetRequest(context, photoType, extension, options);
3349    // Ensure that the asset specified by fileUri exists.
3350    let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
3351    assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, fileUri);
3352    await phAccessHelper.applyChanges(assetChangeRequest);
3353    console.info('apply createAssetRequest successfully');
3354  } catch (err) {
3355    console.error(`createAssetRequestDemo failed with error: ${err.code}, ${err.message}`);
3356  }
3357}
3358```
3359
3360### deleteAssets<sup>11+</sup>
3361
3362static deleteAssets(context: Context, assets: Array&lt;PhotoAsset&gt;): Promise&lt;void&gt;
3363
3364Deletes media assets. This API uses a promise to return the result. The deleted assets are moved to the trash.
3365
3366**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3367
3368**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3369
3370**Parameters**
3371
3372| Name | Type   | Mandatory| Description                      |
3373| ------- | ------- | ---- | -------------------------- |
3374| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
3375| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Array of assets to delete. |
3376
3377**Return value**
3378
3379| Type                                   | Description             |
3380| --------------------------------------- | ----------------- |
3381| Promise&lt;void&gt;| Promise that returns no value.|
3382
3383**Error codes**
3384
3385For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3386
3387| ID| Error Message|
3388| -------- | ---------------------------------------- |
3389| 201      |  Permission denied.         |
3390| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3391| 14000011 |  System inner fail.         |
3392
3393**Example**
3394
3395```ts
3396import { dataSharePredicates } from '@kit.ArkData';
3397
3398async function example() {
3399  console.info('deleteAssetsDemo');
3400  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3401  let fetchOptions: photoAccessHelper.FetchOptions = {
3402    fetchColumns: [],
3403    predicates: predicates
3404  };
3405  try {
3406    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3407    let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects();
3408    await photoAccessHelper.MediaAssetChangeRequest.deleteAssets(context, photoAssetList);
3409    console.info('deleteAssets successfully');
3410  } catch (err) {
3411    console.error(`deleteAssetsDemo failed with error: ${err.code}, ${err.message}`);
3412  }
3413}
3414```
3415
3416### deleteAssets<sup>11+</sup>
3417
3418static deleteAssets(context: Context, uriList: Array&lt;string&gt;): Promise&lt;void&gt;
3419
3420Deletes media assets. This API uses a promise to return the result. The deleted assets are moved to the trash.
3421
3422**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3423
3424**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3425
3426**Parameters**
3427
3428| Name | Type   | Mandatory| Description                      |
3429| ------- | ------- | ---- | -------------------------- |
3430| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
3431| uriList | Array&lt;string&gt; | Yes  | URIs of the media files to delete. |
3432
3433**Return value**
3434
3435| Type                                   | Description             |
3436| --------------------------------------- | ----------------- |
3437| Promise&lt;void&gt;| Promise that returns no value.|
3438
3439**Error codes**
3440
3441For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3442
3443| ID| Error Message|
3444| -------- | ---------------------------------------- |
3445| 201      |  Permission denied.         |
3446| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3447| 14000002 |  Invalid asset uri.         |
3448| 14000011 |  System inner fail.         |
3449
3450**Example**
3451
3452```ts
3453import { dataSharePredicates } from '@kit.ArkData';
3454
3455async function example() {
3456  console.info('deleteAssetsDemo');
3457  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3458  let fetchOptions: photoAccessHelper.FetchOptions = {
3459    fetchColumns: [],
3460    predicates: predicates
3461  };
3462  try {
3463    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3464    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3465    await photoAccessHelper.MediaAssetChangeRequest.deleteAssets(context, [asset.uri]);
3466    console.info('deleteAssets successfully');
3467  } catch (err) {
3468    console.error(`deleteAssetsDemo failed with error: ${err.code}, ${err.message}`);
3469  }
3470}
3471```
3472
3473### getAsset<sup>11+</sup>
3474
3475getAsset(): PhotoAsset
3476
3477Obtains the asset in this asset change request.
3478
3479> **NOTE**<br>For the change request used to create an asset, this API returns **null** before [applyChanges](#applychanges11) is called to apply the changes.
3480
3481**Atomic service API**: This API can be used in atomic services since API version 12.
3482
3483**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3484
3485**Return value**
3486
3487| Type                                   | Description             |
3488| --------------------------------------- | ----------------- |
3489| [PhotoAsset](#photoasset) | Asset obtained.|
3490
3491**Error codes**
3492
3493For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3494
3495| ID| Error Message|
3496| -------- | ---------------------------------------- |
3497| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3498| 14000011 |  System inner fail.         |
3499
3500**Example**
3501
3502```ts
3503async function example() {
3504  console.info('getAssetDemo');
3505  try {
3506    // Ensure that the asset specified by fileUri exists.
3507    let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
3508    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createImageAssetRequest(context, fileUri);
3509    await phAccessHelper.applyChanges(assetChangeRequest);
3510    let asset: photoAccessHelper.PhotoAsset = assetChangeRequest.getAsset();
3511    console.info('create asset successfully with uri = ' + asset.uri);
3512  } catch (err) {
3513    console.error(`getAssetDemo failed with error: ${err.code}, ${err.message}`);
3514  }
3515}
3516```
3517
3518### setTitle<sup>11+</sup>
3519
3520setTitle(title: string): void
3521
3522Sets the media asset title.
3523
3524**Atomic service API**: This API can be used in atomic services since API version 12.
3525
3526**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3527
3528**Parameters**
3529
3530| Name       | Type     | Mandatory  | Description                                |
3531| ---------- | ------- | ---- | ---------------------------------- |
3532| title | string | Yes  | Title to set.|
3533
3534The title must meet the following requirements:
3535- It does not contain a file name extension.
3536- The file name cannot exceed 255 characters.
3537- It does not contain any of the following characters:<br> . \ / : * ? " ' ` < > | { } [ ]
3538
3539**Error codes**
3540
3541For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3542
3543| ID| Error Message|
3544| -------- | ---------------------------------------- |
3545| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3546| 14000011       | System inner fail.         |
3547
3548**Example**
3549
3550```ts
3551import { dataSharePredicates } from '@kit.ArkData';
3552import { BusinessError } from '@kit.BasicServicesKit';
3553
3554async function example() {
3555  console.info('setTitleDemo');
3556  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3557  let fetchOption: photoAccessHelper.FetchOptions = {
3558    fetchColumns: [],
3559    predicates: predicates
3560  };
3561  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
3562  let asset = await fetchResult.getFirstObject();
3563  let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
3564  let newTitle: string = 'newTitle';
3565  assetChangeRequest.setTitle(newTitle);
3566  phAccessHelper.applyChanges(assetChangeRequest).then(() => {
3567    console.info('apply setTitle successfully');
3568  }).catch((err: BusinessError) => {
3569    console.error(`apply setTitle failed with error: ${err.code}, ${err.message}`);
3570  });
3571}
3572```
3573
3574### getWriteCacheHandler<sup>11+</sup>
3575
3576getWriteCacheHandler(): Promise&lt;number&gt;
3577
3578Obtains the handler used for writing a file to cache.
3579
3580> **NOTE**<br>For the same asset change request, this API cannot be repeatedly called after a temporary file write handle is successfully obtained.
3581
3582**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3583
3584**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3585
3586**Return value**
3587
3588| Type                                   | Description             |
3589| --------------------------------------- | ----------------- |
3590| Promise&lt;number&gt; | Promise used to return the write handle obtained.|
3591
3592**Error codes**
3593
3594For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3595
3596| ID| Error Message|
3597| -------- | ---------------------------------------- |
3598| 201   | Permission denied.        |
3599| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3600| 14000011 |  System inner fail.         |
3601| 14000016 |  Operation Not Support.     |
3602
3603**Example**
3604
3605```ts
3606import { fileIo } from '@kit.CoreFileKit';
3607
3608async function example() {
3609  console.info('getWriteCacheHandlerDemo');
3610  try {
3611    let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.VIDEO;
3612    let extension: string = 'mp4';
3613    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createAssetRequest(context, photoType, extension);
3614    let fd: number = await assetChangeRequest.getWriteCacheHandler();
3615    console.info('getWriteCacheHandler successfully');
3616    // write date into fd..
3617    await fileIo.close(fd);
3618    await phAccessHelper.applyChanges(assetChangeRequest);
3619  } catch (err) {
3620    console.error(`getWriteCacheHandlerDemo failed with error: ${err.code}, ${err.message}`);
3621  }
3622}
3623```
3624
3625### addResource<sup>11+</sup>
3626
3627addResource(type: ResourceType, fileUri: string): void
3628
3629Adds a resource using **fileUri**.
3630
3631> **NOTE**<br>For the same asset change request, this API cannot be repeatedly called after the resource is successfully added. For a moving photo, you can call this API twice to add the image and video resources.
3632
3633**Atomic service API**: This API can be used in atomic services since API version 11.
3634
3635**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3636
3637**Parameters**
3638
3639| Name | Type   | Mandatory| Description                      |
3640| ------- | ------- | ---- | -------------------------- |
3641| type | [ResourceType](#resourcetype11) | Yes  | Type of the resource to add.|
3642| fileUri | string | Yes  | Data source of the resource to be added, which is specified by a URI in the application sandbox directory. Example: **'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg'**.|
3643
3644**Error codes**
3645
3646For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3647
3648| ID| Error Message|
3649| -------- | ---------------------------------------- |
3650| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3651| 13900002      |  No such file.   |
3652| 14000011 |  System inner fail.         |
3653| 14000016 |  Operation Not Support.     |
3654
3655**Example**
3656
3657```ts
3658async function example() {
3659  console.info('addResourceByFileUriDemo');
3660  try {
3661    let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
3662    let extension: string = 'jpg';
3663    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createAssetRequest(context, photoType, extension);
3664    // Ensure that the asset specified by fileUri exists.
3665    let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
3666    assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, fileUri);
3667    await phAccessHelper.applyChanges(assetChangeRequest);
3668    console.info('addResourceByFileUri successfully');
3669  } catch (err) {
3670    console.error(`addResourceByFileUriDemo failed with error: ${err.code}, ${err.message}`);
3671  }
3672}
3673```
3674
3675### addResource<sup>11+</sup>
3676
3677addResource(type: ResourceType, data: ArrayBuffer): void
3678
3679Adds a resource using **ArrayBuffer** data.
3680
3681> **NOTE**<br>For the same asset change request, this API cannot be repeatedly called after the resource is successfully added. For a moving photo, you can call this API twice to add the image and video resources.
3682
3683**Atomic service API**: This API can be used in atomic services since API version 11.
3684
3685**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3686
3687**Parameters**
3688
3689| Name | Type   | Mandatory| Description                      |
3690| ------- | ------- | ---- | -------------------------- |
3691| type | [ResourceType](#resourcetype11) | Yes  | Type of the resource to add.|
3692| data | ArrayBuffer | Yes  | Data of the resource to add.|
3693
3694**Error codes**
3695
3696For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3697
3698| ID| Error Message|
3699| -------- | ---------------------------------------- |
3700| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3701| 14000011 |  System inner fail.         |
3702| 14000016 |  Operation Not Support.     |
3703
3704**Example**
3705
3706```ts
3707async function example() {
3708  console.info('addResourceByArrayBufferDemo');
3709  try {
3710    let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
3711    let extension: string = 'jpg';
3712    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createAssetRequest(context, photoType, extension);
3713    let buffer: ArrayBuffer = new ArrayBuffer(2048);
3714    assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, buffer);
3715    await phAccessHelper.applyChanges(assetChangeRequest);
3716    console.info('addResourceByArrayBuffer successfully');
3717  } catch (err) {
3718    console.error(`addResourceByArrayBufferDemo failed with error: ${err.code}, ${err.message}`);
3719  }
3720}
3721```
3722
3723### saveCameraPhoto<sup>12+</sup>
3724
3725saveCameraPhoto(): void
3726
3727Saves the photo taken by the camera.
3728
3729**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3730
3731**Error codes**
3732
3733For details about the error codes, see [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3734
3735| ID| Error Message|
3736| -------- | ---------------------------------------- |
3737| 14000011 |  System inner fail.         |
3738| 14000016 |  Operation Not Support.         |
3739
3740**Example**
3741
3742```ts
3743async function example(asset: photoAccessHelper.PhotoAsset) {
3744  console.info('saveCameraPhotoDemo');
3745  try {
3746    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
3747    assetChangeRequest.saveCameraPhoto();
3748    await phAccessHelper.applyChanges(assetChangeRequest);
3749    console.info('apply saveCameraPhoto successfully');
3750  } catch (err) {
3751    console.error(`apply saveCameraPhoto failed with error: ${err.code}, ${err.message}`);
3752  }
3753}
3754```
3755
3756### saveCameraPhoto<sup>13+</sup>
3757
3758saveCameraPhoto(imageFileType: ImageFileType): void
3759
3760Saves the photo taken by the camera.
3761
3762**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3763
3764**Parameters**
3765
3766| Name  | Type                     | Mandatory| Description      |
3767| -------- | ------------------------- | ---- | ---------- |
3768| imageFileType | [ImageFileType](#imagefiletype13)  | Yes  | File type of the photo to save.|
3769
3770**Error codes**
3771
3772For details about the error codes, see [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3773
3774| ID| Error Message|
3775| -------- | ---------------------------------------- |
3776| 14000011 |  System inner fail.         |
3777| 14000016 |  Operation Not Support.         |
3778
3779**Example**
3780
3781```ts
3782import { photoAccessHelper } from '@kit.MediaLibraryKit';
3783import { dataSharePredicates } from '@kit.ArkData';
3784import { image } from '@kit.ImageKit';
3785
3786async function example(asset: photoAccessHelper.PhotoAsset) {
3787  console.info('saveCameraPhotoDemo');
3788  try {
3789    let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
3790    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
3791    assetChangeRequest.saveCameraPhoto(photoAccessHelper.ImageFileType.JPEG);
3792    await phAccessHelper.applyChanges(assetChangeRequest);
3793    console.info('apply saveCameraPhoto successfully');
3794  } catch (err) {
3795    console.error(`apply saveCameraPhoto failed with error: ${err.code}, ${err.message}`);
3796  }
3797}
3798```
3799
3800### discardCameraPhoto<sup>12+</sup>
3801
3802discardCameraPhoto(): void
3803
3804Discards the photo taken by the camera.
3805
3806**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3807
3808**Error codes**
3809
3810For details about the error codes, see [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3811
3812| ID| Error Message|
3813| -------- | ---------------------------------------- |
3814| 14000011 |  Internal system error.         |
3815| 14000016 |  Operation Not Support.         |
3816
3817**Example**
3818
3819```ts
3820async function example(asset: photoAccessHelper.PhotoAsset) {
3821  console.info('discardCameraPhotoDemo');
3822  try {
3823    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
3824    assetChangeRequest.discardCameraPhoto();
3825    await phAccessHelper.applyChanges(assetChangeRequest);
3826    console.info('apply discardCameraPhoto successfully');
3827  } catch (err) {
3828    console.error(`apply discardCameraPhoto failed with error: ${err.code}, ${err.message}`);
3829  }
3830}
3831```
3832
3833### setOrientation<sup>15+</sup>
3834
3835setOrientation(orientation: number): void
3836
3837Sets the orientation of this image.
3838
3839**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3840
3841**Parameters**
3842
3843| Name       | Type     | Mandatory  | Description                                |
3844| ---------- | ------- | ---- | ---------------------------------- |
3845| orientation | number | Yes  | Rotation angle of the image to set. The value can only be **0**, **90**, **180**, or **270**.|
3846
3847**Error codes**
3848
3849For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3850
3851| ID| Error Message|
3852| -------- | ---------------------------------------- |
3853| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3854| 14000011 |  Internal system error.         |
3855
3856**Example**
3857
3858```ts
3859import { dataSharePredicates } from '@kit.ArkData';
3860import { BusinessError } from '@kit.BasicServicesKit';
3861
3862async function example() {
3863  console.info('setOrientationDemo');
3864  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3865  let fetchOption: photoAccessHelper.FetchOptions = {
3866    fetchColumns: [],
3867    predicates: predicates
3868  };
3869  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
3870  let asset = await fetchResult.getFirstObject();
3871  let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
3872  assetChangeRequest.setOrientation(90);
3873  phAccessHelper.applyChanges(assetChangeRequest).then(() => {
3874    console.info('apply setOrientation successfully');
3875  }).catch((err: BusinessError) => {
3876    console.error(`apply setOrientation failed with error: ${err.code}, ${err.message}`);
3877  });
3878}
3879```
3880
3881## MediaAlbumChangeRequest<sup>11+</sup>
3882
3883Provides APIs for managing the media album change request.
3884
3885**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3886
3887### constructor<sup>11+</sup>
3888
3889constructor(album: Album)
3890
3891Constructor.
3892
3893**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3894
3895**Parameters**
3896
3897| Name  | Type                     | Mandatory| Description      |
3898| -------- | ------------------------- | ---- | ---------- |
3899| album | [Album](#album) | Yes  | Album to change.|
3900
3901**Error codes**
3902
3903For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3904
3905| ID| Error Message|
3906| -------- | ---------------------------------------- |
3907| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3908| 14000011       | System inner fail.          |
3909
3910**Example**
3911
3912```ts
3913import { dataSharePredicates } from '@kit.ArkData';
3914
3915async function example() {
3916  console.info('MediaAlbumChangeRequest constructorDemo');
3917  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3918  let fetchOptions: photoAccessHelper.FetchOptions = {
3919    fetchColumns: [],
3920    predicates: predicates
3921  };
3922  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions);
3923  let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
3924  let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
3925}
3926```
3927
3928### getAlbum<sup>11+</sup>
3929
3930getAlbum(): Album
3931
3932Obtains the album in the current album change request.
3933
3934> **NOTE**<br>For the change request for creating an album, this API returns **null** before [applyChanges](#applychanges11) is called to apply the changes.
3935
3936**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3937
3938**Return value**
3939
3940| Type                                   | Description             |
3941| --------------------------------------- | ----------------- |
3942| [Album](#album) | Album obtained.|
3943
3944**Error codes**
3945
3946For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3947
3948| ID| Error Message|
3949| -------- | ---------------------------------------- |
3950| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3951| 14000011 |  System inner fail.         |
3952
3953**Example**
3954
3955```ts
3956async function example() {
3957  console.info('getAlbumDemo');
3958  try {
3959    // Ensure that the user album exists in the gallery.
3960    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
3961    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
3962    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
3963    let changeRequestAlbum: photoAccessHelper.Album = albumChangeRequest.getAlbum();
3964    console.info('change request album uri: ' + changeRequestAlbum.albumUri);
3965  } catch (err) {
3966    console.error(`getAlbumDemo failed with error: ${err.code}, ${err.message}`);
3967  }
3968}
3969```
3970
3971### setAlbumName<sup>11+</sup>
3972
3973setAlbumName(name: string): void
3974
3975Sets the album name.
3976
3977The album name must comply with the following specifications:
3978- It does not exceed 255 characters.
3979- It does not contain any of the following characters:<br> . \ / : * ? " ' ` < > | { } [ ]
3980- It is case-insensitive.
3981- Duplicate album names are not allowed.
3982
3983**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3984
3985**Parameters**
3986
3987| Name       | Type     | Mandatory  | Description                                |
3988| ---------- | ------- | ---- | ---------------------------------- |
3989| name | string | Yes  | Album name to set.|
3990
3991**Error codes**
3992
3993For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3994
3995| ID| Error Message|
3996| -------- | ---------------------------------------- |
3997| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3998| 14000011       | System inner fail.         |
3999
4000**Example**
4001
4002```ts
4003async function example() {
4004  console.info('setAlbumNameDemo');
4005  try {
4006    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
4007    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
4008    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
4009    let newAlbumName: string = 'newAlbumName' + new Date().getTime();
4010    albumChangeRequest.setAlbumName(newAlbumName);
4011    await phAccessHelper.applyChanges(albumChangeRequest);
4012    console.info('setAlbumName successfully');
4013  } catch (err) {
4014    console.error(`setAlbumNameDemo failed with error: ${err.code}, ${err.message}`);
4015  }
4016}
4017```
4018
4019### addAssets<sup>11+</sup>
4020
4021addAssets(assets: Array&lt;PhotoAsset&gt;): void
4022
4023Add assets to the album.
4024
4025**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4026
4027**Parameters**
4028
4029| Name       | Type     | Mandatory  | Description                                |
4030| ---------- | ------- | ---- | ---------------------------------- |
4031| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Array of assets to add. |
4032
4033**Error codes**
4034
4035For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4036
4037| ID| Error Message|
4038| -------- | ---------------------------------------- |
4039| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4040| 14000011       | System inner fail.         |
4041| 14000016 |  Operation Not Support.     |
4042
4043**Example**
4044
4045```ts
4046import { dataSharePredicates } from '@kit.ArkData';
4047
4048async function example() {
4049  console.info('addAssetsDemo');
4050  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4051  let fetchOptions: photoAccessHelper.FetchOptions = {
4052    fetchColumns: [],
4053    predicates: predicates
4054  };
4055  try {
4056    // Ensure that user albums and photos exist in Gallery.
4057    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
4058    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
4059    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
4060    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
4061    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
4062    albumChangeRequest.addAssets([asset]);
4063    await phAccessHelper.applyChanges(albumChangeRequest);
4064    console.info('addAssets successfully');
4065  } catch (err) {
4066    console.error(`addAssetsDemo failed with error: ${err.code}, ${err.message}`);
4067  }
4068}
4069```
4070
4071### removeAssets<sup>11+</sup>
4072
4073removeAssets(assets: Array&lt;PhotoAsset&gt;): void
4074
4075Removes assets from the album.
4076
4077**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4078
4079**Parameters**
4080
4081| Name       | Type     | Mandatory  | Description                                |
4082| ---------- | ------- | ---- | ---------------------------------- |
4083| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Array of assets to remove. |
4084
4085**Error codes**
4086
4087For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4088
4089| ID| Error Message|
4090| -------- | ---------------------------------------- |
4091| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4092| 14000011       | System inner fail.         |
4093| 14000016 |  Operation Not Support.     |
4094
4095**Example**
4096
4097```ts
4098import { dataSharePredicates } from '@kit.ArkData';
4099
4100async function example() {
4101  console.info('removeAssetsDemo');
4102  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4103  let fetchOptions: photoAccessHelper.FetchOptions = {
4104    fetchColumns: [],
4105    predicates: predicates
4106  };
4107  try {
4108    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
4109    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
4110    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions);
4111    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
4112
4113    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
4114    albumChangeRequest.removeAssets([asset]);
4115    await phAccessHelper.applyChanges(albumChangeRequest);
4116    console.info('removeAssets successfully');
4117  } catch (err) {
4118    console.error(`removeAssetsDemo failed with error: ${err.code}, ${err.message}`);
4119  }
4120}
4121```
4122
4123## MediaAssetManager<sup>11+</sup>
4124
4125A media asset manager class, used for manipulating the read and write operations of media assets.
4126
4127**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4128
4129### requestImage<sup>11+</sup>
4130
4131static requestImage(context: Context, asset: PhotoAsset, requestOptions: RequestOptions, dataHandler: MediaAssetDataHandler&lt;image.ImageSource&gt;): Promise&lt;string&gt;
4132
4133Requests an image.
4134
4135**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4136
4137**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4138
4139- When you call this API in Picker mode, you do not need to request the ohos.permission.READ_IMAGEVIDEO permission. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
4140- For the media assets saved to the media library by this application, the application can access them without the ohos.permission.READ_IMAGEVIDEO permission.
4141
4142**Parameters**
4143
4144| Name           | Type                                                                                                       | Mandatory| Description                     |
4145|----------------|-----------------------------------------------------------------------------------------------------------| ---- | ------------------------- |
4146| context        | [Context](../apis-ability-kit/js-apis-inner-application-context.md)                                                           | Yes  | Context of the ability instance.|
4147| asset         | [PhotoAsset](#photoasset)                                                                                | Yes  | Image to request.|
4148| requestOptions | [RequestOptions](#requestoptions11)                                                                        | Yes  | Options for requesting the image.|
4149| dataHandler    | [MediaAssetDataHandler](#mediaassetdatahandler11)&lt;[image.ImageSource](../apis-image-kit/js-apis-image.md#imagesource)&gt; | Yes  | Media asset handler, which invokes a callback to return the image when the requested image is ready.|
4150
4151**Return value**
4152
4153| Type                                   | Description             |
4154| --------------------------------------- | ----------------- |
4155| Promise\<string> | Promise used to return the request ID, which can be used in [cancelRequest](#cancelrequest12) to cancel a request.|
4156
4157**Error codes**
4158
4159For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4160
4161| ID| Error Message|
4162| -------- | ---------------------------------------- |
4163| 201      |  Permission denied         |
4164| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4165| 14000011       | System inner fail.         |
4166
4167**Example**
4168
4169```ts
4170import { dataSharePredicates } from '@kit.ArkData';
4171import { image } from '@kit.ImageKit';
4172
4173class MediaHandler implements photoAccessHelper.MediaAssetDataHandler<image.ImageSource> {
4174  onDataPrepared(data: image.ImageSource) {
4175    if (data === undefined) {
4176      console.error('Error occurred when preparing data');
4177      return;
4178    }
4179    console.info('on image data prepared');
4180  }
4181}
4182
4183async function example() {
4184  console.info('requestImage');
4185  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4186  let fetchOptions: photoAccessHelper.FetchOptions = {
4187    fetchColumns: [],
4188    predicates: predicates
4189  };
4190  let requestOptions: photoAccessHelper.RequestOptions = {
4191    deliveryMode: photoAccessHelper.DeliveryMode.HIGH_QUALITY_MODE,
4192  }
4193  const handler = new MediaHandler();
4194
4195  phAccessHelper.getAssets(fetchOptions, async (err, fetchResult) => {
4196      console.info('fetchResult success');
4197      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
4198      await photoAccessHelper.MediaAssetManager.requestImage(context, photoAsset, requestOptions, handler);
4199      console.info('requestImage successfully');
4200  });
4201}
4202```
4203
4204### requestImageData<sup>11+</sup>
4205
4206static requestImageData(context: Context, asset: PhotoAsset, requestOptions: RequestOptions, dataHandler: MediaAssetDataHandler&lt;ArrayBuffer&gt;): Promise&lt;string&gt;
4207
4208Requests image data.
4209
4210**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4211
4212**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4213
4214- When you call this API in Picker mode, you do not need to request the ohos.permission.READ_IMAGEVIDEO permission. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
4215- For the media assets saved to the media library by this application, the application can access them without the ohos.permission.READ_IMAGEVIDEO permission.
4216
4217**Parameters**
4218
4219| Name  | Type                                                                  | Mandatory| Description                     |
4220| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
4221| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md)                      | Yes  | Context of the ability instance.|
4222| asset | [PhotoAsset](#photoasset)                                            | Yes  | Image to request.|
4223| requestOptions  | [RequestOptions](#requestoptions11)                                  | Yes  | Options for requesting the image.|
4224| dataHandler  | [MediaAssetDataHandler](#mediaassetdatahandler11)&lt;ArrayBuffer&gt; | Yes  | Media asset handler, which invokes a callback to return the image when the requested image is ready.|
4225
4226**Return value**
4227
4228| Type                                   | Description             |
4229| --------------------------------------- | ----------------- |
4230| Promise\<string> | Promise used to return the request ID, which can be used in [cancelRequest](#cancelrequest12) to cancel a request.|
4231
4232**Error codes**
4233
4234For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4235
4236| ID| Error Message|
4237| -------- | ---------------------------------------- |
4238| 201      |  Permission denied         |
4239| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4240| 14000011       | System inner fail.         |
4241
4242**Example**
4243
4244```ts
4245import { dataSharePredicates } from '@kit.ArkData';
4246class MediaDataHandler implements photoAccessHelper.MediaAssetDataHandler<ArrayBuffer> {
4247  onDataPrepared(data: ArrayBuffer) {
4248    if (data === undefined) {
4249      console.error('Error occurred when preparing data');
4250      return;
4251    }
4252    console.info('on image data prepared');
4253  }
4254}
4255
4256async function example() {
4257  console.info('requestImageData');
4258  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4259  let fetchOptions: photoAccessHelper.FetchOptions = {
4260    fetchColumns: [],
4261    predicates: predicates
4262  };
4263  let requestOptions: photoAccessHelper.RequestOptions = {
4264    deliveryMode: photoAccessHelper.DeliveryMode.HIGH_QUALITY_MODE,
4265  }
4266  const handler = new MediaDataHandler();
4267
4268  phAccessHelper.getAssets(fetchOptions, async (err, fetchResult) => {
4269      console.info('fetchResult success');
4270      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
4271      await photoAccessHelper.MediaAssetManager.requestImageData(context, photoAsset, requestOptions, handler);
4272      console.info('requestImageData successfully');
4273  });
4274}
4275```
4276
4277### requestMovingPhoto<sup>12+</sup>
4278
4279static requestMovingPhoto(context: Context, asset: PhotoAsset, requestOptions: RequestOptions, dataHandler: MediaAssetDataHandler&lt;MovingPhoto&gt;): Promise&lt;string&gt;
4280
4281Requests a moving photo object, which can be used to request the asset data of the moving photo.
4282
4283**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4284
4285**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4286
4287- When you call this API in Picker mode, you do not need to request the ohos.permission.READ_IMAGEVIDEO permission. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
4288- For the moving photos saved to the media library by this application, the application can access them without the ohos.permission.READ_IMAGEVIDEO permission.
4289
4290**Parameters**
4291
4292| Name  | Type                                                                  | Mandatory| Description                     |
4293| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
4294| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md)                      | Yes  | Context of the ability instance.|
4295| asset | [PhotoAsset](#photoasset)                                            | Yes  | Image to request.|
4296| requestOptions  | [RequestOptions](#requestoptions11)                                  | Yes  | Options for requesting the image.|
4297| dataHandler  | [MediaAssetDataHandler](#mediaassetdatahandler11)&lt;[MovingPhoto](#movingphoto12)&gt; | Yes  | Media asset handler, which invokes a callback to return the image when the requested image is ready.|
4298
4299**Return value**
4300
4301| Type                                   | Description             |
4302| --------------------------------------- | ----------------- |
4303| Promise\<string> | Promise used to return the request ID, which can be used in [cancelRequest](#cancelrequest12) to cancel a request.|
4304
4305**Error codes**
4306
4307For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4308
4309| ID| Error Message|
4310| -------- | ---------------------------------------- |
4311| 201      |  Permission denied         |
4312| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4313| 801   | Capability not supported.       |
4314| 14000011       | System inner fail         |
4315
4316**Example**
4317
4318```ts
4319import { dataSharePredicates } from '@kit.ArkData';
4320
4321class MovingPhotoHandler implements photoAccessHelper.MediaAssetDataHandler<photoAccessHelper.MovingPhoto> {
4322  async onDataPrepared(movingPhoto: photoAccessHelper.MovingPhoto) {
4323    if (movingPhoto === undefined) {
4324      console.error('Error occurred when preparing data');
4325      return;
4326    }
4327    console.info("moving photo acquired successfully, uri: " + movingPhoto.getUri());
4328  }
4329}
4330
4331async function example() {
4332  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4333  predicates.equalTo(photoAccessHelper.PhotoKeys.PHOTO_SUBTYPE, photoAccessHelper.PhotoSubtype.MOVING_PHOTO);
4334  let fetchOptions: photoAccessHelper.FetchOptions = {
4335    fetchColumns: [],
4336    predicates: predicates
4337  };
4338  // Ensure that there are moving photos in Gallery.
4339  let assetResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
4340  let asset: photoAccessHelper.PhotoAsset = await assetResult.getFirstObject();
4341  let requestOptions: photoAccessHelper.RequestOptions = {
4342    deliveryMode: photoAccessHelper.DeliveryMode.FAST_MODE,
4343  }
4344  const handler = new MovingPhotoHandler();
4345  try {
4346    let requestId: string = await photoAccessHelper.MediaAssetManager.requestMovingPhoto(context, asset, requestOptions, handler);
4347    console.info("moving photo requested successfully, requestId: " + requestId);
4348  } catch (err) {
4349    console.error(`failed to request moving photo, error code is ${err.code}, message is ${err.message}`);
4350  }
4351}
4352
4353```
4354
4355### requestVideoFile<sup>12+</sup>
4356
4357static requestVideoFile(context: Context, asset: PhotoAsset, requestOptions: RequestOptions, fileUri: string, dataHandler: MediaAssetDataHandler&lt;boolean&gt;): Promise&lt;string&gt;
4358
4359Requests a video and saves it to the specified sandbox directory.
4360
4361**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4362
4363**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4364
4365- When you call this API in Picker mode, you do not need to request the ohos.permission.READ_IMAGEVIDEO permission. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
4366- For the videos saved to the media library by this application, the application can access them without the ohos.permission.READ_IMAGEVIDEO permission.
4367
4368**Parameters**
4369
4370| Name  | Type                                                                  | Mandatory| Description                     |
4371| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
4372| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md)                      | Yes  | Context of the ability instance.|
4373| asset | [PhotoAsset](#photoasset)                                            | Yes  | Image to request.|
4374| requestOptions  | [RequestOptions](#requestoptions11)                                  | Yes  | Options for requesting the video asset.|
4375| fileUri| string                                                              | Yes| URI of the sandbox directory, to which the requested video asset is to be saved. Example: **'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.mp4'**.|
4376| dataHandler  | [MediaAssetDataHandler](#mediaassetdatahandler11)&lt;boolean&gt; | Yes  | Media asset handler. When the requested video is written to the specified directory, a callback is triggered.|
4377
4378**Return value**
4379
4380| Type                                   | Description             |
4381| --------------------------------------- | ----------------- |
4382| Promise\<string> | Promise used to return the request ID, which can be used in [cancelRequest](#cancelrequest12) to cancel a request.|
4383
4384**Error codes**
4385
4386For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4387
4388| ID| Error Message|
4389| -------- | ---------------------------------------- |
4390| 201      |  Permission denied         |
4391| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4392| 801<sup>15+</sup>   | Capability not supported.       |
4393| 14000011       | System inner fail.         |
4394
4395**Example**
4396
4397```ts
4398import { dataSharePredicates } from '@kit.ArkData';
4399class MediaDataHandler implements photoAccessHelper.MediaAssetDataHandler<boolean> {
4400    onDataPrepared(data: boolean) {
4401        console.info('on video request status prepared');
4402    }
4403}
4404
4405async function example() {
4406  console.info('requestVideoFile');
4407  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4408  let fetchOptions: photoAccessHelper.FetchOptions = {
4409    fetchColumns: [],
4410    predicates: predicates
4411  };
4412  let requestOptions: photoAccessHelper.RequestOptions = {
4413    deliveryMode: photoAccessHelper.DeliveryMode.HIGH_QUALITY_MODE,
4414  }
4415  const handler = new MediaDataHandler();
4416  let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.mp4';
4417  phAccessHelper.getAssets(fetchOptions, async (err, fetchResult) => {
4418      console.info('fetchResult success');
4419      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
4420      await photoAccessHelper.MediaAssetManager.requestVideoFile(context, photoAsset, requestOptions, fileUri, handler);
4421      console.info('requestVideoFile successfully');
4422  });
4423}
4424```
4425
4426### cancelRequest<sup>12+</sup>
4427
4428static cancelRequest(context: Context, requestId: string): Promise\<void>
4429
4430Cancels a request for the asset, the callback of which has not been triggered yet.
4431
4432**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4433
4434**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4435
4436**Parameters**
4437
4438| Name  | Type                                                                  | Mandatory| Description                     |
4439| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
4440| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md)                      | Yes  | Context of the ability instance.|
4441| requestId | string     | Yes  | ID of the request to cancel. It is a valid request ID returned by **requestImage**.|
4442
4443**Return value**
4444
4445| Type                                   | Description             |
4446| --------------------------------------- | ----------------- |
4447| Promise\<void> | Promise that returns no value.|
4448
4449**Error codes**
4450
4451For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4452
4453| ID| Error Message|
4454| -------- | ---------------------------------------- |
4455| 201      |  Permission denied         |
4456| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4457| 14000011       | System inner fail         |
4458
4459**Example**
4460
4461```ts
4462import { dataSharePredicates } from '@kit.ArkData';
4463
4464async function example() {
4465  try {
4466    let requestId: string = 'xxx-xxx'; // A valid requestId returned by APIs such as requestImage() must be used.
4467    await photoAccessHelper.MediaAssetManager.cancelRequest(context, requestId);
4468    console.info("request cancelled successfully");
4469  } catch (err) {
4470    console.error(`cancelRequest failed with error: ${err.code}, ${err.message}`);
4471  }
4472}
4473
4474```
4475
4476### loadMovingPhoto<sup>12+</sup>
4477
4478static loadMovingPhoto(context: Context, imageFileUri: string, videoFileUri: string): Promise\<MovingPhoto>
4479
4480Loads a moving photo in the application sandbox.
4481
4482**Atomic service API**: This API can be used in atomic services since API version 14.
4483
4484**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4485
4486**Parameters**
4487
4488| Name  | Type                                                                  | Mandatory| Description                     |
4489| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
4490| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md)   | Yes  | **AbilityContext** or **UIExtensionContext** instance.|
4491| imageFileUri | string     | Yes  | URI of the image file of the moving photo in the application sandbox.|
4492| videoFileUri | string     | Yes  | URI of the video file of the moving photo in the application sandbox.|
4493
4494**Return value**
4495
4496| Type                                   | Description             |
4497| --------------------------------------- | ----------------- |
4498| Promise\<MovingPhoto> | Promise used to return a [MovingPhoto](#movingphoto12) instance.|
4499
4500**Error codes**
4501
4502For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4503
4504| ID| Error Message|
4505| -------- | ---------------------------------------- |
4506| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4507| 14000011 | Internal system error. |
4508
4509**Example**
4510
4511```ts
4512async function example() {
4513  try {
4514    let imageFileUri: string = 'file://com.example.temptest/data/storage/el2/base/haps/ImageFile.jpg'; // URI of the image file of the moving photo in the application sandbox.
4515    let videoFileUri: string = 'file://com.example.temptest/data/storage/el2/base/haps/VideoFile.mp4'; // URI of the video file of the moving photo in the application sandbox.
4516    let movingPhoto: photoAccessHelper.MovingPhoto = await photoAccessHelper.MediaAssetManager.loadMovingPhoto(context, imageFileUri, videoFileUri);
4517  } catch (err) {
4518    console.error(`loadMovingPhoto failed with error: ${err.code}, ${err.message}`);
4519  }
4520}
4521
4522```
4523
4524### quickRequestImage<sup>13+</sup>
4525
4526static quickRequestImage(context: Context, asset: PhotoAsset, requestOptions: RequestOptions, dataHandler: QuickImageDataHandler&lt;image.Picture&gt;): Promise&lt;string&gt;
4527
4528Requests an image quickly.
4529
4530**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4531
4532**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4533
4534- When you call this API in Picker mode, you do not need to request the ohos.permission.READ_IMAGEVIDEO permission. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
4535
4536**Parameters**
4537
4538| Name           | Type                                                                                                       | Mandatory| Description                     |
4539|----------------|-----------------------------------------------------------------------------------------------------------| ---- | ------------------------- |
4540| context        | [Context](../apis-ability-kit/js-apis-inner-application-context.md)                                                           | Yes  | Context of the ability instance.|
4541| asset         | [PhotoAsset](#photoasset)                                                                                | Yes  | Image to request.|
4542| requestOptions | [RequestOptions](#requestoptions11)                                                                        | Yes  | Options for requesting the image.|
4543| dataHandler    | [QuickImageDataHandler](#quickimagedatahandler13)&lt;[image.Picture](../apis-image-kit/js-apis-image.md#picture13)&gt; | Yes  | Media asset handler, which invokes a callback to return the image when the requested image is ready.|
4544
4545**Return value**
4546
4547| Type                                   | Description             |
4548| --------------------------------------- | ----------------- |
4549| Promise\<string> | Promise used to return the request ID, which can be used in [cancelRequest](#cancelrequest12) to cancel a request.|
4550
4551**Error codes**
4552
4553For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4554
4555| ID| Error Message|
4556| -------- | ---------------------------------------- |
4557| 201      |  Permission denied         |
4558| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4559| 14000011       | Internal system error.         |
4560
4561**Example**
4562
4563```ts
4564import { photoAccessHelper } from '@kit.MediaLibraryKit';
4565import { dataSharePredicates } from '@kit.ArkData';
4566import { image } from '@kit.ImageKit';
4567
4568class MediaHandler implements photoAccessHelper.QuickImageDataHandler<image.Picture> {
4569  onDataPrepared(data: image.Picture, imageSource: image.ImageSource, map: Map<string, string>) {
4570    console.info('on image data prepared');
4571  }
4572}
4573
4574async function example() {
4575  console.info('quickRequestImage');
4576  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4577  let fetchOptions: photoAccessHelper.FetchOptions = {
4578    fetchColumns: [],
4579    predicates: predicates
4580  };
4581  let requestOptions: photoAccessHelper.RequestOptions = {
4582    deliveryMode: photoAccessHelper.DeliveryMode.HIGH_QUALITY_MODE,
4583  }
4584  const handler = new MediaHandler();
4585  let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
4586  phAccessHelper.getAssets(fetchOptions, async (err, fetchResult) => {
4587      console.info('fetchResult success');
4588      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
4589      await photoAccessHelper.MediaAssetManager.quickRequestImage(context, photoAsset, requestOptions, handler);
4590      console.info('quickRequestImage successfully');
4591  });
4592}
4593```
4594
4595## MediaAssetDataHandler<sup>11+</sup>
4596
4597Media asset handler, which can be used to customize the media asset processing logic in **onDataPrepared**.
4598
4599**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4600
4601### onDataPrepared<sup>11+</sup>
4602
4603onDataPrepared(data: T, map?: Map<string, string>): void
4604
4605Called when the requested media asset is ready. If an error occurs, **data** returned by the callback is **undefined**. Each media asset request corresponds to a callback.
4606T supports the following data types: ArrayBuffer, [ImageSource](../apis-image-kit/js-apis-image.md#imagesource), [MovingPhoto](#movingphoto12), and boolean. ArrayBuffer indicates the image or video asset data, [ImageSource](../apis-image-kit/js-apis-image.md#imagesource) indicates the image source, [MovingPhoto](#movingphoto12) indicates a moving photo object, and boolean indicates whether the image or video is successfully written to the application sandbox directory.
4607
4608Information returned by **map**:
4609| Map Key | **Description**|
4610|----------|-------|
4611| 'quality'  | Image quality. The value **high** means high quality, and **low** means poor quality.|
4612
4613**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4614
4615**Parameters**
4616
4617| Name | Type| Mandatory| Description                                                                           |
4618|------|---| ---- |-------------------------------------------------------------------------------|
4619| data | T | Yes  | Data of the image asset that is ready. The value supports the following types: ArrayBuffer, [ImageSource](../apis-image-kit/js-apis-image.md#imagesource), [MovingPhoto](#movingphoto12), and boolean.|
4620| map<sup>12+</sup> | Map<string, string> | No  | Additional information about the image asset, such as the image quality. Currently, only **quality** is supported.|
4621
4622**Example**
4623```ts
4624import { image } from '@kit.ImageKit';
4625
4626class MediaHandler implements photoAccessHelper.MediaAssetDataHandler<image.ImageSource> {
4627  onDataPrepared = (data: image.ImageSource, map: Map<string, string>) => {
4628    if (data === undefined) {
4629      console.error('Error occurred when preparing data');
4630      return;
4631    }
4632    // Customize the processing logic for ImageSource.
4633    console.info('on image data prepared, photo quality is ' + map['quality']);
4634  }
4635}
4636
4637class MediaDataHandler implements photoAccessHelper.MediaAssetDataHandler<ArrayBuffer> {
4638  onDataPrepared = (data: ArrayBuffer, map: Map<string, string>) => {
4639    if (data === undefined) {
4640      console.error('Error occurred when preparing data');
4641      return;
4642    }
4643    // Customize the processing logic for ArrayBuffer.
4644    console.info('on image data prepared, photo quality is ' + map['quality']);
4645  }
4646}
4647
4648class MovingPhotoHandler implements photoAccessHelper.MediaAssetDataHandler<photoAccessHelper.MovingPhoto> {
4649  onDataPrepared = (data: photoAccessHelper.MovingPhoto, map: Map<string, string>) => {
4650    if (data === undefined) {
4651      console.error('Error occurred when preparing data');
4652      return;
4653    }
4654    // Customize the processing logic for MovingPhoto.
4655    console.info('on image data prepared, photo quality is ' + map['quality']);
4656  }
4657}
4658```
4659
4660## QuickImageDataHandler<sup>13+</sup>
4661
4662Media asset handler, which can be used to customize the media asset processing logic in **onDataPrepared**.
4663
4664**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4665
4666### onDataPrepared<sup>13+</sup>
4667
4668onDataPrepared(data: T, imageSource: image.ImageSource, map: Map<string, string>): void
4669
4670Called when the requested image is ready. If an error occurs, **data** returned by the callback is **undefined**.
4671**T** supports the Picture data type.
4672
4673Information returned by **map**:
4674| Map Key | **Description**|
4675|----------|-------|
4676| 'quality'  | Image quality. The value **high** means high quality, and **low** means poor quality.|
4677
4678**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4679
4680**Parameters**
4681
4682| Name | Type| Mandatory| Description                                                                           |
4683|------|---| ---- |-------------------------------------------------------------------------------|
4684| data | T | Yes  | Data of the image asset that is ready. It is of the T type, which supports the [Picture](../apis-image-kit/js-apis-image.md#picture13) type.|
4685| imageSource | image.ImageSource | Yes  | Data of the image asset that is ready.|
4686| map<sup>13+</sup> | Map<string, string> | Yes  | Additional information about the image asset, such as the image quality. Currently, only **quality** is supported.|
4687
4688**Example**
4689```ts
4690import { image } from '@kit.ImageKit';
4691
4692class MediaHandler implements photoAccessHelper.QuickImageDataHandler<image.Picture> {
4693  onDataPrepared(data: image.Picture, imageSource: image.ImageSource, map: Map<string, string>) {
4694    console.info('on image data prepared');
4695  }
4696}
4697```
4698
4699## MovingPhoto<sup>12+</sup>
4700
4701Provides APIs for managing a moving photo instance.
4702
4703**Atomic service API**: This API can be used in atomic services since API version 12.
4704
4705**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4706
4707### getUri<sup>12+</sup>
4708
4709getUri(): string
4710
4711Obtains the URI of this moving photo.
4712
4713**Atomic service API**: This API can be used in atomic services since API version 12.
4714
4715**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4716
4717**Return value**
4718
4719| Type                                   | Description             |
4720| --------------------------------------- | ----------------- |
4721| string | URI of the moving photo obtained.|
4722
4723**Error codes**
4724
4725For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4726
4727| ID| Error Message|
4728| -------- | ---------------------------------------- |
4729| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4730| 14000011 |  System inner fail.         |
4731
4732**Example**
4733
4734```ts
4735import { dataSharePredicates } from '@kit.ArkData';
4736
4737class MovingPhotoHandler implements photoAccessHelper.MediaAssetDataHandler<photoAccessHelper.MovingPhoto> {
4738  async onDataPrepared(movingPhoto: photoAccessHelper.MovingPhoto) {
4739    if (movingPhoto === undefined) {
4740      console.error('Error occurred when preparing data');
4741      return;
4742    }
4743    console.info("moving photo acquired successfully, uri: " + movingPhoto.getUri());
4744  }
4745}
4746
4747async function example() {
4748  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4749  predicates.equalTo(photoAccessHelper.PhotoKeys.PHOTO_SUBTYPE, photoAccessHelper.PhotoSubtype.MOVING_PHOTO);
4750  let fetchOptions: photoAccessHelper.FetchOptions = {
4751    fetchColumns: [],
4752    predicates: predicates
4753  };
4754  // Ensure that there are moving photos in Gallery.
4755  let assetResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
4756  let asset: photoAccessHelper.PhotoAsset = await assetResult.getFirstObject();
4757  let requestOptions: photoAccessHelper.RequestOptions = {
4758    deliveryMode: photoAccessHelper.DeliveryMode.FAST_MODE,
4759  }
4760  const handler = new MovingPhotoHandler();
4761  try {
4762    let requestId: string = await photoAccessHelper.MediaAssetManager.requestMovingPhoto(context, asset, requestOptions, handler);
4763    console.info("moving photo requested successfully, requestId: " + requestId);
4764  } catch (err) {
4765    console.error(`failed to request moving photo, error code is ${err.code}, message is ${err.message}`);
4766  }
4767}
4768```
4769
4770### requestContent<sup>12+</sup>
4771
4772requestContent(imageFileUri: string, videoFileUri: string): Promise\<void>
4773
4774Requests the image data and video data of this moving photo and writes them to the specified URIs, respectively.
4775
4776**Atomic service API**: This API can be used in atomic services since API version 12.
4777
4778**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4779
4780**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4781
4782- When you call this API in Picker mode, you do not need to request the ohos.permission.READ_IMAGEVIDEO permission. For details, see [Accessing and Managing Moving Photos](../../media/medialibrary/photoAccessHelper-movingphoto.md).
4783- For the moving photos saved to the media library by this application, the application can access them without the ohos.permission.READ_IMAGEVIDEO permission.
4784
4785**Parameters**
4786
4787| Name  | Type                                                                  | Mandatory| Description                     |
4788| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
4789| imageFileUri | string                      | Yes  | URI to which the image data of the moving photo is to be written. Example: **"file://com.example.temptest/data/storage/el2/base/haps/ImageFile.jpg"**.|
4790| videoFileUri | string                                            | Yes  | URI to which the video data of the moving photo is to be written. Example: **"file://com.example.temptest/data/storage/el2/base/haps/VideoFile.mp4"**.|
4791
4792**Return value**
4793
4794| Type                                   | Description             |
4795| --------------------------------------- | ----------------- |
4796| Promise\<void> | Promise that returns no value.|
4797
4798**Error codes**
4799
4800For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4801
4802| ID| Error Message|
4803| -------- | ---------------------------------------- |
4804| 201      |  Permission denied   |
4805| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4806| 14000011 |  System inner fail         |
4807
4808**Example**
4809
4810```ts
4811import { dataSharePredicates } from '@kit.ArkData';
4812
4813class MovingPhotoHandler implements photoAccessHelper.MediaAssetDataHandler<photoAccessHelper.MovingPhoto> {
4814  async onDataPrepared(movingPhoto: photoAccessHelper.MovingPhoto) {
4815    if (movingPhoto === undefined) {
4816      console.error('Error occurred when preparing data');
4817      return;
4818    }
4819    // The URIs must be valid.
4820    let imageFileUri: string = "file://com.example.temptest/data/storage/el2/base/haps/ImageFile.jpg";
4821    let videoFileUri: string = "file://com.example.temptest/data/storage/el2/base/haps/VideoFile.mp4";
4822    try {
4823      await movingPhoto.requestContent(imageFileUri, videoFileUri);
4824      console.log("moving photo contents retrieved successfully");
4825    } catch (err) {
4826      console.error(`failed to retrieve contents of moving photo, error code is ${err.code}, message is ${err.message}`);
4827    }
4828  }
4829}
4830
4831async function example() {
4832  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4833  predicates.equalTo(photoAccessHelper.PhotoKeys.PHOTO_SUBTYPE, photoAccessHelper.PhotoSubtype.MOVING_PHOTO);
4834  let fetchOptions: photoAccessHelper.FetchOptions = {
4835    fetchColumns: [],
4836    predicates: predicates
4837  };
4838  // Ensure that there are moving photos in Gallery.
4839  let assetResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
4840  let asset: photoAccessHelper.PhotoAsset = await assetResult.getFirstObject();
4841  let requestOptions: photoAccessHelper.RequestOptions = {
4842    deliveryMode: photoAccessHelper.DeliveryMode.FAST_MODE,
4843  }
4844  const handler = new MovingPhotoHandler();
4845  try {
4846    let requestId: string = await photoAccessHelper.MediaAssetManager.requestMovingPhoto(context, asset, requestOptions, handler);
4847    console.info("moving photo requested successfully, requestId: " + requestId);
4848  } catch (err) {
4849    console.error(`failed to request moving photo, error code is ${err.code}, message is ${err.message}`);
4850  }
4851}
4852```
4853
4854### requestContent<sup>12+</sup>
4855
4856requestContent(resourceType: ResourceType, fileUri: string): Promise\<void>
4857
4858Requests the moving photo content of the specified resource type and writes it to the specified URI.
4859
4860**Atomic service API**: This API can be used in atomic services since API version 12.
4861
4862**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4863
4864**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4865
4866- When you call this API in Picker mode, you do not need to request the ohos.permission.READ_IMAGEVIDEO permission. For details, see [Accessing and Managing Moving Photos](../../media/medialibrary/photoAccessHelper-movingphoto.md).
4867- For the moving photos saved to the media library by this application, the application can access them without the ohos.permission.READ_IMAGEVIDEO permission.
4868
4869**Parameters**
4870
4871| Name  | Type                                                                  | Mandatory| Description                     |
4872| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
4873| resourceType | [ResourceType](#resourcetype11)                      | Yes  | Resource type of the moving photo content to request.|
4874| fileUri | string                                                    | Yes  |URI to which the moving photo content is to be written.|
4875
4876**Return value**
4877
4878| Type                                   | Description             |
4879| --------------------------------------- | ----------------- |
4880| Promise\<void> | Promise that returns no value.|
4881
4882**Error codes**
4883
4884For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4885
4886| ID| Error Message|
4887| -------- | ---------------------------------------- |
4888| 201      |  Permission denied   |
4889| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4890| 14000011 |  System inner fail         |
4891
4892**Example**
4893
4894```ts
4895import { dataSharePredicates } from '@kit.ArkData';
4896
4897class MovingPhotoHandler implements photoAccessHelper.MediaAssetDataHandler<photoAccessHelper.MovingPhoto> {
4898  async onDataPrepared(movingPhoto: photoAccessHelper.MovingPhoto) {
4899    if (movingPhoto === undefined) {
4900      console.error('Error occurred when preparing data');
4901      return;
4902    }
4903    // The URIs must be valid.
4904    let imageFileUri: string = "file://com.example.temptest/data/storage/el2/base/haps/ImageFile.jpg";
4905    try {
4906      await movingPhoto.requestContent(photoAccessHelper.ResourceType.IMAGE_RESOURCE, imageFileUri);
4907      console.log("moving photo image content retrieved successfully");
4908    } catch (err) {
4909      console.error(`failed to retrieve image content of moving photo, error code is ${err.code}, message is ${err.message}`);
4910    }
4911  }
4912}
4913
4914async function example() {
4915  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4916  predicates.equalTo(photoAccessHelper.PhotoKeys.PHOTO_SUBTYPE, photoAccessHelper.PhotoSubtype.MOVING_PHOTO);
4917  let fetchOptions: photoAccessHelper.FetchOptions = {
4918    fetchColumns: [],
4919    predicates: predicates
4920  };
4921  // Ensure that there are moving photos in Gallery.
4922  let assetResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
4923  let asset: photoAccessHelper.PhotoAsset = await assetResult.getFirstObject();
4924  let requestOptions: photoAccessHelper.RequestOptions = {
4925    deliveryMode: photoAccessHelper.DeliveryMode.FAST_MODE,
4926  }
4927  const handler = new MovingPhotoHandler();
4928  try {
4929    let requestId: string = await photoAccessHelper.MediaAssetManager.requestMovingPhoto(context, asset, requestOptions, handler);
4930    console.info("moving photo requested successfully, requestId: " + requestId);
4931  } catch (err) {
4932    console.error(`failed to request moving photo, error code is ${err.code}, message is ${err.message}`);
4933  }
4934}
4935```
4936
4937### requestContent<sup>12+</sup>
4938
4939requestContent(resourceType: ResourceType): Promise\<ArrayBuffer>
4940
4941Requests the moving photo content of the specified resource type and returns it in ArrayBuffer format.
4942
4943**Atomic service API**: This API can be used in atomic services since API version 12.
4944
4945**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4946
4947**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4948
4949- When you call this API in Picker mode, you do not need to request the ohos.permission.READ_IMAGEVIDEO permission. For details, see [Accessing and Managing Moving Photos](../../media/medialibrary/photoAccessHelper-movingphoto.md).
4950- For the moving photos saved to the media library by this application, the application can access them without the ohos.permission.READ_IMAGEVIDEO permission.
4951
4952**Parameters**
4953
4954| Name  | Type                                                                  | Mandatory| Description                     |
4955| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
4956| resourceType | [ResourceType](#resourcetype11)                      | Yes  | Resource type of the moving photo content to request.|
4957
4958**Return value**
4959
4960| Type                                   | Description             |
4961| --------------------------------------- | ----------------- |
4962| Promise\<ArrayBuffer> | Promise used to return the requested content in an ArrayBuffer.|
4963
4964**Error codes**
4965
4966For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4967
4968| ID| Error Message|
4969| -------- | ---------------------------------------- |
4970| 201      |  Permission denied   |
4971| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4972| 14000011 |  System inner fail         |
4973
4974**Example**
4975
4976```ts
4977import { dataSharePredicates } from '@kit.ArkData';
4978
4979class MovingPhotoHandler implements photoAccessHelper.MediaAssetDataHandler<photoAccessHelper.MovingPhoto> {
4980  async onDataPrepared(movingPhoto: photoAccessHelper.MovingPhoto) {
4981    if (movingPhoto === undefined) {
4982      console.error('Error occurred when preparing data');
4983      return;
4984    }
4985    try {
4986      let buffer: ArrayBuffer = await movingPhoto.requestContent(photoAccessHelper.ResourceType.IMAGE_RESOURCE);
4987      console.log("moving photo image content retrieved successfully, buffer length: " + buffer.byteLength);
4988    } catch (err) {
4989      console.error(`failed to retrieve image content of moving photo, error code is ${err.code}, message is ${err.message}`);
4990    }
4991  }
4992}
4993
4994async function example() {
4995  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4996  predicates.equalTo(photoAccessHelper.PhotoKeys.PHOTO_SUBTYPE, photoAccessHelper.PhotoSubtype.MOVING_PHOTO);
4997  let fetchOptions: photoAccessHelper.FetchOptions = {
4998    fetchColumns: [],
4999    predicates: predicates
5000  };
5001  // Ensure that there are moving photos in Gallery.
5002  let assetResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
5003  let asset: photoAccessHelper.PhotoAsset = await assetResult.getFirstObject();
5004  let requestOptions: photoAccessHelper.RequestOptions = {
5005    deliveryMode: photoAccessHelper.DeliveryMode.FAST_MODE,
5006  }
5007  const handler = new MovingPhotoHandler();
5008  try {
5009    let requestId: string = await photoAccessHelper.MediaAssetManager.requestMovingPhoto(context, asset, requestOptions, handler);
5010    console.info("moving photo requested successfully, requestId: " + requestId);
5011  } catch (err) {
5012    console.error(`failed to request moving photo, error code is ${err.code}, message is ${err.message}`);
5013  }
5014}
5015```
5016
5017## MemberType
5018
5019type MemberType = number | string | boolean
5020
5021Defines the types of the **PhotoAsset** members.
5022
5023The member types are the union of the types listed in the following table.
5024
5025**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5026
5027| Type| Description|
5028| ---- | ---- |
5029| number | The member value is any number.|
5030| string | The member value is any string.|
5031| boolean | The member value is true or false.|
5032
5033## PhotoType
5034
5035Enumerates media file types.
5036
5037**Atomic service API**: This API can be used in atomic services since API version 11.
5038
5039**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5040
5041| Name |  Value|  Description|
5042| ----- |  ---- |  ---- |
5043| IMAGE |  1 |  Image.|
5044| VIDEO |  2 |  Video.|
5045
5046## PhotoSubtype<sup>12+</sup>
5047
5048Enumerates the [PhotoAsset](#photoasset) types.
5049
5050**Atomic service API**: This API can be used in atomic services since API version 12.
5051
5052**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5053
5054| Name |  Value|  Description|
5055| ----- |  ---- |  ---- |
5056| DEFAULT |  0 |  Photo, which is the default type.|
5057| MOVING_PHOTO |  3 |  Moving photo.|
5058| BURST |  4 |  Burst photo.|
5059
5060## DynamicRangeType<sup>12+</sup>
5061
5062Enumerates the formats for displaying media assets.
5063
5064**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5065
5066| Name |  Value|  Description|
5067| ----- |  ---- |  ---- |
5068| SDR |  0 |  Standard dynamic range (SDR).|
5069| HDR |  1 |  High dynamic range (HDR). |
5070
5071## AlbumType
5072
5073Enumerates the album types.
5074
5075**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5076
5077| Name                 | Value   | Description                       |
5078| ------------------- | ---- | ------------------------- |
5079| USER                | 0    | User album.                    |
5080| SYSTEM              | 1024 | System album.                  |
5081
5082## AlbumSubtype
5083
5084Enumerate the album subtypes.
5085
5086**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5087
5088| Name                               | Value         | Description                             |
5089| --------------------------------- | ---------- | ------------------------------- |
5090| USER\_GENERIC                     | 1          | User album.                          |
5091| FAVORITE                          | 1025       | Favorites.                           |
5092| VIDEO                             | 1026       | Video album.                          |
5093| IMAGE<sup>12+</sup>               | 1031       | Photo album.                          |
5094| ANY                               | 2147483647 | Any album.                          |
5095
5096## PositionType<sup>16+</sup>
5097
5098Enumerates the file locations.
5099
5100**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5101
5102| Name |  Value|  Description|
5103| ----- |  ---- |  ---- |
5104| LOCAL |  1  |  Stored only on a local device.|
5105| CLOUD |  2  |  Stored only on the cloud.|
5106| LOCAL_AND_CLOUD |  3  |  Stored both on a local device and cloud.|
5107
5108## PhotoKeys
5109
5110Defines the key information about an image or video file.
5111
5112**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5113
5114| Name         | Value             | Description                                                      |
5115| ------------- | ------------------- | ---------------------------------------------------------- |
5116| URI           | 'uri'                 | URI of the file.<br>**NOTE**: Only the [DataSharePredicates.equalTo](../apis-arkdata/js-apis-data-dataSharePredicates.md#equalto10) predicate can be used for this field during photo query.           |
5117| PHOTO_TYPE    | 'media_type'           | Type of the file.                                             |
5118| DISPLAY_NAME  | 'display_name'        | File name displayed.                                                  |
5119| SIZE          | 'size'                | File size, in bytes. The size of a moving photo includes the total size of the image and video.   |
5120| DATE_ADDED    | 'date_added'          | Unix timestamp when the file was created, in seconds.            |
5121| DATE_MODIFIED | 'date_modified'       | Unix timestamp when the file was modified, in seconds. This value is updated when the file content is modified, but not when the file name is modified.|
5122| DURATION      | 'duration'            | Duration, in ms.                                   |
5123| WIDTH         | 'width'               | Image width, in pixels.                                   |
5124| HEIGHT        | 'height'              | Image height, in pixels.                                     |
5125| DATE_TAKEN    | 'date_taken'          | Unix timestamp when the image was captured, in seconds.               |
5126| ORIENTATION   | 'orientation'         | Orientation of the file, in degrees.                                            |
5127| FAVORITE      | 'is_favorite'            | Whether the file is added to favorites.                                                   |
5128| TITLE         | 'title'               | Title in the file.                                                  |
5129| DATE_ADDED_MS<sup>12+</sup>  | 'date_added_ms'          | Unix timestamp when the file was created, in milliseconds.<br>**NOTE**: The photos queried cannot be sorted based on this field. |
5130| DATE_MODIFIED_MS<sup>12+</sup>  | 'date_modified_ms'    | Unix timestamp when the file was modified, in milliseconds. This value is updated when the file content is modified, but not when the file name is modified.<br>**NOTE**: The photos queried cannot be sorted based on this field.|
5131| PHOTO_SUBTYPE<sup>12+</sup>   | 'subtype'               | Subtype of the media file.                                                  |
5132| DYNAMIC_RANGE_TYPE<sup>12+</sup>   | 'dynamic_range_type'               | Dynamic range type of the media asset.                                                 |
5133| COVER_POSITION<sup>12+</sup>   | 'cover_position'               | Position of the moving photo cover, which is the video timestamp (in μs) corresponding to the cover frame.|
5134| BURST_KEY<sup>12+</sup>   | 'burst_key'               | Unique ID of a group of burst photos.|
5135| LCD_SIZE<sup>12+</sup>  | 'lcd_size'  | Width and height of an LCD image, in the format of a **width:height** string.|
5136| THM_SIZE<sup>12+</sup>  | 'thm_size'  | Width and height of a thumbnail image, in the format of a **width:height** string.|
5137| DETAIL_TIME<sup>13+</sup>  | 'detail_time'  | Detailed time. The value is a string of time when the image or video was taken in the time zone and does not change with the time zone.|
5138| DATE_TAKEN_MS<sup>13+</sup>  | 'date_taken_ms'  | Unix timestamp when the image was captured, in milliseconds.|
5139| POSITION<sup>16+</sup>  | 'position'            | File location type.                              |
5140
5141## AlbumKeys
5142
5143Enumerates the key album attributes.
5144
5145**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5146
5147| Name         | Value             | Description                                                      |
5148| ------------- | ------------------- | ---------------------------------------------------------- |
5149| URI           | 'uri'                 | URI of the album.                                                  |
5150| ALBUM_NAME    | 'album_name'          | Name of the album.                                                  |
5151
5152## CreateOptions
5153
5154Options for creating an image or video asset.
5155
5156The title must meet the following requirements:
5157- It does not contain a file name extension.
5158- The file name cannot exceed 255 characters.
5159- It does not contain any of the following characters:<br> . .. \ / : * ? " ' ` < > | { } [ ]
5160
5161**Atomic service API**: This API can be used in atomic services since API version 11.
5162
5163**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5164
5165| Name                  | Type               | Mandatory| Description                                             |
5166| ---------------------- | ------------------- | ---- | ------------------------------------------------ |
5167| title                  | string                          | No | Title of the image or video. |
5168| subtype<sup>12+</sup>  | [PhotoSubtype](#photosubtype12) | No | Subtype of the image or video file.<br>**Atomic service API**: This API can be used in atomic services since API version 12. |
5169
5170
5171## FetchOptions
5172
5173Defines the options for fetching media files.
5174
5175**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5176
5177| Name                  | Type               | Readable| Writable| Description                                             |
5178| ---------------------- | ------------------- | ---- |---- | ------------------------------------------------ |
5179| fetchColumns           | Array&lt;string&gt; | Yes  | Yes  | Names of the columns specified for query.<br>If this parameter is left blank for photos, photos are fetched by **'uri'**, **'media_type'**, **'subtype'**, and **'display_name'** by default. An error will be thrown if [get](#get) is used to obtain other attributes of this object. <br>Example: **fetchColumns: ['uri', 'title']**.<br>If this parameter is left blank for albums, albums are fetched by **'uri'** and **'album_name'** by default. |
5180| predicates           | [dataSharePredicates.DataSharePredicates](../apis-arkdata/js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes  | Yes  | Predicates that specify the fetch criteria.|
5181
5182## RequestOptions<sup>11+</sup>
5183
5184Represents request options.
5185
5186**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5187
5188| Name                  | Type                       | Read-Only| Optional| Description                                        |
5189| ---------------------- |----------------------------| ---- | ---- | ------------------------------------------- |
5190| deliveryMode           | [DeliveryMode](#deliverymode11) | No  | No  | Delivery mode of the requested asset. The value can be **FAST_MODE**, **HIGH_QUALITY_MODE**, or **BALANCE_MODE**.|
5191| compatibleMode<sup>15+</sup>      | [CompatibleMode](#compatiblemode15) | No  | Yes  | HDR video transcoding policy, which can be **FAST_ORIGINAL_FORMAT_MODE** (maintaining the original HDR format) or **COMPATIBLE_FORMAT_MODE** (converting HDR content to SDR format). The default value is **FAST_ORIGINAL_FORMAT_MODE**.|
5192| mediaAssetProgressHandler<sup>15+</sup> | [MediaAssetProgressHandler](#mediaassetprogresshandler15) | No  | Yes  | Callback used to return the HDR-to-SDR conversion progress.|
5193
5194## MediaChangeRequest<sup>11+</sup>
5195
5196Media change request, which is the parent class of the asset change request and album change request.
5197
5198> **NOTE**<br>**MediaChangeRequest** takes effect only after [applyChanges](#applychanges11) is called.
5199
5200**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5201
5202## ResourceType<sup>11+</sup>
5203
5204Enumerates the types of the resources to write.
5205
5206**Atomic service API**: This API can be used in atomic services since API version 11.
5207
5208**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5209
5210| Name |  Value|  Description|
5211| ----- |  ---- |  ---- |
5212| IMAGE_RESOURCE |  1 |  Image resource.|
5213| VIDEO_RESOURCE |  2 |  Video resource.|
5214
5215## ImageFileType<sup>13+</sup>
5216
5217Enumerates the types of image files to save.
5218
5219**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5220
5221| Name |  Value|  Description|
5222| ----- |  ---- |  ---- |
5223| JPEG  |  1 |  JPEG.|
5224| HEIF  |  2 |  HEIF.|
5225
5226## ChangeData
5227
5228Defines the return value of the listener callback.
5229
5230**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5231
5232| Name   | Type                       | Readable| Writable| Description                                                        |
5233| ------- | --------------------------- | ---- | ---- | ------------------------------------------------------------ |
5234| type    | [NotifyType](#notifytype) | Yes  | No  | Notification type.                                      |
5235| uris    | Array&lt;string&gt;         | Yes  | No  | All URIs with the same [NotifyType](#notifytype), which can be **PhotoAsset** or **Album**.|
5236| extraUris | Array&lt;string&gt;         | Yes  | No  | URIs of the changed files in the album.                                   |
5237
5238## NotifyType
5239
5240Enumerates the notification event types.
5241
5242**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5243
5244| Name                     | Value  | Description                            |
5245| ------------------------- | ---- | -------------------------------- |
5246| NOTIFY_ADD                | 0    | A file asset or album is added.    |
5247| NOTIFY_UPDATE             | 1    | A file asset or album is updated.    |
5248| NOTIFY_REMOVE             | 2    | A file asset or album is removed.    |
5249| NOTIFY_ALBUM_ADD_ASSET    | 3    | A file asset is added to the album.|
5250| NOTIFY_ALBUM_REMOVE_ASSET | 4    | A file asset is removed from the album.|
5251
5252## DefaultChangeUri
5253
5254Enumerates the **DefaultChangeUri** subtypes.
5255
5256**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5257
5258| Name             | Value                     | Description                                                        |
5259| ----------------- | ----------------------- | ------------------------------------------------------------ |
5260| DEFAULT_PHOTO_URI | 'file://media/Photo'      | Default **PhotoAsset** URI, which must be used with **forChildUris{true}** to subscribe to change notifications of all photo assets.|
5261| DEFAULT_ALBUM_URI | 'file://media/PhotoAlbum' | Default album URI, which must be used with **forChildUris{true}** to subscribe to change notifications of all albums.|
5262
5263## PhotoViewMIMETypes
5264
5265Enumerates the media file types that can be selected.
5266
5267**Atomic service API**: This API can be used in atomic services since API version 11.
5268
5269**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5270
5271| Name                                   |  Value| Description      |
5272|---------------------------------------|  ---- |----------|
5273| IMAGE_TYPE                            |  'image/*' | Image.   |
5274| VIDEO_TYPE                            |  'video/*' | Video.   |
5275| IMAGE_VIDEO_TYPE                      |  '\*/*' | Image and video.|
5276| MOVING_PHOTO_IMAGE_TYPE<sup>12+</sup> |  'image/movingPhoto' | Moving photo.<br>**Atomic service API**: This API can be used in atomic services since API version 12. |
5277
5278## RecommendationType<sup>11+</sup>
5279
5280Enumerates the types of recommended images.
5281
5282**Atomic service API**: This API can be used in atomic services since API version 11.
5283
5284**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5285
5286| Name |  Value|  Description|
5287| ----- |  ---- | ---- |
5288| QR_OR_BAR_CODE  |  1 | QR code or barcode.|
5289| QR_CODE |  2 | QR code.|
5290| BAR_CODE |  3 | Barcode.|
5291| ID_CARD |  4 | ID card.|
5292| PROFILE_PICTURE |  5 | Profile.|
5293| PASSPORT<sup>12+</sup> |  6 | passport.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
5294| BANK_CARD<sup>12+</sup> |  7 | Bank card.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
5295| DRIVER_LICENSE<sup>12+</sup> |  8 | Driver license.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
5296| DRIVING_LICENSE<sup>12+</sup> |  9 | Vehicle license<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
5297| FEATURED_SINGLE_PORTRAIT<sup>12+</sup> |  10 | Recommended portrait.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
5298
5299**Example**
5300
5301```ts
5302import { BusinessError } from '@kit.BasicServicesKit';
5303async function example() {
5304  try {
5305    let recommendOptions: photoAccessHelper.RecommendationOptions = {
5306      recommendationType: photoAccessHelper.RecommendationType.ID_CARD
5307    }
5308    let options: photoAccessHelper.PhotoSelectOptions = {
5309      MIMEType: photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE,
5310      maxSelectNumber: 1,
5311      recommendationOptions: recommendOptions
5312    }
5313    let photoPicker = new photoAccessHelper.PhotoViewPicker();
5314    photoPicker.select(options).then((PhotoSelectResult: photoAccessHelper.PhotoSelectResult) => {
5315      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
5316    }).catch((err: BusinessError) => {
5317      console.error(`PhotoViewPicker.select failed with err: ${err.code}, ${err.message}`);
5318    });
5319  } catch (error) {
5320    let err: BusinessError = error as BusinessError;
5321    console.error(`PhotoViewPicker failed with err: ${err.code}, ${err.message}`);
5322  }
5323}
5324```
5325
5326## TextContextInfo<sup>12+</sup>
5327
5328Represents the text information about the recommended images.
5329
5330**Atomic service API**: This API can be used in atomic services since API version 12.
5331
5332**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5333
5334| Name                   | Type               | Mandatory| Description                         |
5335| ----------------------- | ------------------- | ---- | -------------------------------- |
5336| text | string   | No  | Text based on which images are recommended. The text cannot exceed 250 characters. The default value is an empty string.|
5337
5338**Example**
5339
5340```ts
5341import { BusinessError } from '@kit.BasicServicesKit';
5342async function example() {
5343  try {
5344    let textInfo: photoAccessHelper.TextContextInfo = {
5345      text: 'Pandas at Shanghai Wild Zoo'
5346    }
5347    let recommendOptions: photoAccessHelper.RecommendationOptions = {
5348      textContextInfo: textInfo
5349    }
5350    let options: photoAccessHelper.PhotoSelectOptions = {
5351      MIMEType: photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE,
5352      maxSelectNumber: 1,
5353      recommendationOptions: recommendOptions
5354    }
5355    let photoPicker = new photoAccessHelper.PhotoViewPicker();
5356    photoPicker.select(options).then((PhotoSelectResult: photoAccessHelper.PhotoSelectResult) => {
5357      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
5358    }).catch((err: BusinessError) => {
5359      console.error(`PhotoViewPicker.select failed with err: ${err.code}, ${err.message}`);
5360    });
5361  } catch (error) {
5362    let err: BusinessError = error as BusinessError;
5363    console.error(`PhotoViewPicker failed with err: ${err.code}, ${err.message}`);
5364  }
5365}
5366```
5367
5368## RecommendationOptions<sup>11+</sup>
5369
5370Defines the image recommendation options. The image recommendation feature depends on the image data analysis capability, which varies with devices.
5371
5372**Atomic service API**: This API can be used in atomic services since API version 11.
5373
5374**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5375
5376| Name                   | Type               | Mandatory| Description                         |
5377| ----------------------- | ------------------- | ---- | -------------------------------- |
5378| recommendationType | [RecommendationType](#recommendationtype11)   | No  | Type of the recommended image.|
5379| textContextInfo<sup>12+</sup> | [TextContextInfo](#textcontextinfo12)   | No  | Text based on which images are recommended. If both **recommendationType** and **textContextInfo** are set, **textContextInfo** takes precedence over **recommendationType**.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
5380
5381## BaseSelectOptions<sup>12+</sup>
5382
5383Defines the basic options for selecting media assets from Gallery.
5384
5385**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5386
5387| Name                   | Type               | Mandatory| Description                         |
5388| ----------------------- | ------------------- | ---- | -------------------------------- |
5389| MIMEType<sup>10+</sup>    | [PhotoViewMIMETypes](#photoviewmimetypes)   | No  | Available media file types. **IMAGE_VIDEO_TYPE** is used by default.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
5390| maxSelectNumber<sup>10+</sup>      | number | No  | Maximum number of media files that can be selected.<br>Maximum value: **500**<br>Default value: **50**<br>**Atomic service API**: This API can be used in atomic services since API version 11.  |
5391| isPhotoTakingSupported<sup>11+</sup> | boolean  | No  | Whether photo taking is supported.<br>The value **true** means photo taking is supported; the value **false** means the opposite.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
5392| isSearchSupported<sup>11+</sup> | boolean  | No  | Whether the image is searchable.<br>The value **true** means the image is searchable; the value **false** means the opposite.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
5393| recommendationOptions<sup>11+</sup>       | [RecommendationOptions](#recommendationoptions11)   | No  | Image recommendation parameters.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
5394| preselectedUris<sup>11+</sup> | Array&lt;string&gt;  | No  | URI of the preselected image.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
5395| isPreviewForSingleSelectionSupported<sup>12+</sup> | boolean  | No  | Whether to enable full image preview if a single image is selected.<br>The value **true** means to enable full image preview; the value **false** means the opposite.<br>Default value: **true**<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
5396
5397## PhotoSelectOptions
5398
5399Defines additional options for selecting media assets from Gallery. It inherits from **BaseSelectOptions**.
5400
5401**Atomic service API**: This API can be used in atomic services since API version 11.
5402
5403**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5404
5405| Name                   | Type               | Mandatory| Description                         |
5406| ----------------------- | ------------------- | ---- | -------------------------------- |
5407| isEditSupported<sup>11+</sup>       | boolean | No  | Whether the image can be edited.<br>The value **true** means the image can be edited; the value **false** means the opposite.    |
5408| isOriginalSupported<sup>12+</sup>       | boolean | No  | Whether to display the button for selecting the original image. <br>The value **true** means to display the button; the value **false** means the opposite.<br>Default value: **false**<br>**Atomic service API**: This API can be used in atomic services since API version 12.    |
5409| subWindowName<sup>12+</sup>       | string | No  | Name of the sub-window.<br>**Atomic service API**: This API can be used in atomic services since API version 12.    |
5410| completeButtonText<sup>14+</sup>       | [CompleteButtonText](#completebuttontext14) | No  | Text displayed on the complete button.<br>The complete button is located in the lower right corner of the page. It is used by users to signify that they have finished selecting images.<br>**Atomic service API**: This API can be used in atomic services since API version 14.    |
5411
5412## PhotoSelectResult
5413
5414Defines information about the images or videos selected.
5415
5416**Atomic service API**: This API can be used in atomic services since API version 11.
5417
5418**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5419
5420| Name                   | Type               | Readable| Writable| Description                          |
5421| ----------------------- | ------------------- | ---- | ---- | ------------------------------ |
5422| photoUris        | Array&lt;string&gt;    | Yes  | Yes  | URIs of the images or videos selected. The URI array can be used only by calling [photoAccessHelper.getAssets](#getassets) with temporary authorization. For details about how to use the media file URI, see [Using a Media File URI](../../file-management/user-file-uri-intro.md#using-a-media-file-uri).|
5423| isOriginalPhoto        | boolean    | Yes  | Yes  | Whether the selected media asset is the original image. The value **true** means that the selected media asset is the original image, and **false** means the opposite. The default value is **false**.|
5424
5425
5426## DeliveryMode<sup>11+</sup>
5427
5428Enumerates the asset delivery modes.
5429
5430**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5431
5432| Name |  Value|  Description|
5433| ----- |  ---- |  ---- |
5434| FAST_MODE |  0 |  Fast mode.|
5435| HIGH_QUALITY_MODE |  1 |  High-quality mode.|
5436| BALANCE_MODE |  2 |  Balance mode.|
5437
5438## PhotoCreationConfig<sup>12+</sup>
5439
5440Represents the configuration for saving a media asset (image or video) to the media library, including the file name.
5441
5442**Atomic service API**: This API can be used in atomic services since API version 12.
5443
5444**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5445
5446| Name                  | Type               | Mandatory| Description                                             |
5447| ---------------------- | ------------------- | ---- | ------------------------------------------------ |
5448| title | string | No | Title of the image or video. If this parameter is not passed, the system generates a title. The title must meet the following requirements:<br>- It does not contain a file name extension.<br>- The file name, which is in the format of title+file name extension, does not exceed 255 characters.<br>- The title does not contain any of the following characters:\ / : * ? " ' ` < > \| { } [ ]|
5449| fileNameExtension | string | Yes | File name extension, for example, **'jpg'**.|
5450| photoType | [PhotoType](#phototype) | Yes | Type of the file to create, which can be **IMAGE** or **VIDEO**. |
5451| subtype | [PhotoSubtype](#photosubtype12) | No | Image or video file subtype. Currently, only **DEFAULT** is supported. |
5452
5453## CompatibleMode<sup>15+</sup>
5454
5455Enumerates the video transcoding mode.
5456
5457**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5458
5459| Name |  Value|  Description|
5460| ----- | ---- | ---- |
5461| ORIGINAL_FORMAT_MODE |  0 |  Maintains the original video format. |
5462| COMPATIBLE_FORMAT_MODE    |  1 |  Converts the HDR content to SDR format.   |
5463
5464## CompleteButtonText<sup>14+</sup>
5465
5466Enumerates the text displayed on the complete button.
5467
5468**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5469
5470| Name |  Value|  Description|
5471| ----- | ---- | ---- |
5472| TEXT_DONE<sup>14+</sup> |  0 |  The text "Done" is displayed.<br>**Atomic service API**: This API can be used in atomic services since API version 14.|
5473| TEXT_SEND<sup>14+</sup>    |  1 |  The text "Send" is displayed.<br>**Atomic service API**: This API can be used in atomic services since API version 14.|
5474| TEXT_ADD<sup>14+</sup> |  2 |  The text "Add" is displayed.<br>**Atomic service API**: This API can be used in atomic services since API version 14. |
5475
5476## MediaAssetProgressHandler<sup>15+</sup>
5477
5478Represents the media asset progress handler, which is used to obtain the media asset processing progress from **onProgress()**.
5479
5480**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5481
5482### onProgress<sup>15+</sup>
5483
5484onProgress(progress: number): void
5485
5486Called when the progress of the requested video is returned.
5487
5488**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5489
5490**Parameters**
5491
5492| Name | Type   | Mandatory| Description                      |
5493| ------- | ------- | ---- | -------------------------- |
5494| progress | number | Yes  | Progress in percentage. <br>Value range: 0 to 100|
5495