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
67If the caller does not have the ohos.permission.READ_IMAGEVIDEO permission, use Picker to access the file and then call this API based on the URI obtained by Picker. 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
124If the caller does not have the ohos.permission.READ_IMAGEVIDEO permission, use Picker to access the file and then call this API based on the URI obtained by Picker. 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)).    |
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 } form '@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-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.|
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.|
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 albums to obtain.             |
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 albums to obtain.             |
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 albums to obtain.             |
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
840If 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).
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.
956
957**Atomic service API**: This API can be used in atomic services since API version 12.
958
959**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
960
961**Parameters**
962
963| Name  | Type                                                                  | Mandatory| Description                     |
964| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
965| 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**: Only image and video URIs are supported.|
966| 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**.|
967
968**Return value**
969
970| Type                                   | Description             |
971| --------------------------------------- | ----------------- |
972| 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.|
973
974**Error codes**
975
976For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
977
978| ID| Error Message|
979| -------- | ---------------------------------------- |
980| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
981| 14000011 |  Internal system error |
982
983**Example**
984
985```ts
986import { dataSharePredicates } from '@kit.ArkData';
987import { photoAccessHelper } from '@kit.MediaLibraryKit';
988
989async function example() {
990  console.info('ShowAssetsCreationDialogDemo.');
991
992  try {
993    // Obtain the sandbox URIs of the images or videos to be saved to the media library.
994    let srcFileUris: Array<string> = [
995      'file://fileUriDemo1' // The URI here is an example only.
996    ];
997    let photoCreationConfigs: Array<photoAccessHelper.PhotoCreationConfig> = [
998      {
999        title: 'test2', // Optional.
1000        fileNameExtension: 'jpg',
1001        photoType: photoAccessHelper.PhotoType.IMAGE,
1002        subtype: photoAccessHelper.PhotoSubtype.DEFAULT, // Optional.
1003      }
1004    ];
1005    let desFileUris: Array<string> = await phAccessHelper.showAssetsCreationDialog(srcFileUris, photoCreationConfigs);
1006    console.info('showAssetsCreationDialog success, data is ' + desFileUris);
1007  } catch (err) {
1008    console.error('showAssetsCreationDialog failed, errCode is ' + err.code + ', errMsg is ' + err.message);
1009  }
1010}
1011```
1012
1013### createAssetWithShortTermPermission<sup>12+</sup>
1014
1015createAssetWithShortTermPermission(photoCreationConfig: PhotoCreationConfig): Promise&lt;string&gt;
1016
1017Creates 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
1018within 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.
1019
1020**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1021
1022**Required permissions**: ohos.permission.SHORT_TERM_WRITE_IMAGEVIDEO
1023
1024**Parameters**
1025
1026| Name  | Type                                                                  | Mandatory| Description                     |
1027| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
1028| photoCreationConfig | [PhotoCreationConfig](#photocreationconfig12); | Yes| Configuration for saving a media asset (image or video) to the media library, including the file name.|
1029
1030**Return value**
1031
1032| Type                                   | Description             |
1033| --------------------------------------- | ----------------- |
1034| 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.|
1035
1036**Error codes**
1037
1038For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1039
1040| ID| Error Message|
1041| -------- | ---------------------------------------- |
1042| 201 | Permission denied |
1043| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1044| 14000011 |  Internal system error |
1045
1046**Example**
1047
1048```ts
1049import { fileIo } from '@kit.CoreFileKit';
1050
1051async function example() {
1052    console.info('createAssetWithShortTermPermissionDemo.');
1053
1054    try {
1055        let photoCreationConfig: photoAccessHelper.PhotoCreationConfig = {
1056            title: '123456',
1057            fileNameExtension: 'jpg',
1058            photoType: photoAccessHelper.PhotoType.IMAGE,
1059            subtype: photoAccessHelper.PhotoSubtype.DEFAULT,
1060        };
1061
1062        let resultUri: string = await phAccessHelper.createAssetWithShortTermPermission(photoCreationConfig);
1063        let resultFile: fileIo.File = fileIo.openSync(resultUri, fileIo.OpenMode.READ_WRITE);
1064        // Use the actual URI and file size.
1065        let srcFile:  fileIo.File = fileIo.openSync("file://test.jpg", fileIo.OpenMode.READ_ONLY);
1066        let bufSize: number = 2000000;
1067        let readSize: number = 0;
1068        let buf = new ArrayBuffer(bufSize);
1069        let readLen = fileIo.readSync(srcFile.fd, buf, {
1070            offset: readSize,
1071            length: bufSize
1072        });
1073        if (readLen > 0) {
1074            readSize += readLen;
1075            fileIo.writeSync(resultFile.fd, buf, { length: readLen });
1076        }
1077        fileIo.closeSync(srcFile);
1078        fileIo.closeSync(resultFile);
1079    } catch (err) {
1080        console.error('createAssetWithShortTermPermission failed, errCode is ' + err.code + ', errMsg is ' + err.message);
1081    }
1082
1083}
1084```
1085
1086### requestPhotoUrisReadPermission<sup>14+</sup>
1087
1088requestPhotoUrisReadPermission(srcFileUris: Array&lt;string&gt;): Promise&lt;Array&lt;string&gt;&gt;
1089
1090<!--RP1--><!--RP1End-->Grants the save permission for URIs. This API uses a promise to return the result.
1091
1092**Atomic service API**: This API can be used in atomic services since API version 14.
1093
1094**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1095
1096**Parameters**
1097
1098| Name  | Type                                                                  | Mandatory| Description                     |
1099| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
1100| 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.|
1101
1102**Return value**
1103
1104| Type                                   | Description             |
1105| --------------------------------------- | ----------------- |
1106| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the URIs granted with the save permission.|
1107
1108**Error codes**
1109
1110For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1111
1112| ID| Error Message|
1113| -------- | ---------------------------------------- |
1114| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1115| 14000011 |  Internal system error |
1116
1117**Example**
1118
1119```ts
1120import { dataSharePredicates } from '@kit.ArkData';
1121import { photoAccessHelper } from '@kit.MediaLibraryKit';
1122
1123async function example() {
1124  console.info('requestPhotoUrisReadPermissionDemo.');
1125
1126  try {
1127    let phAccessHelper: photoAccessHelper.PhotoAccessHelper = photoAccessHelper.getPhotoAccessHelper(this.context);
1128    // Obtain the URIs of the images or videos to be granted with the permission.
1129    let srcFileUris: Array<string> = [
1130      'file://fileUriDemo1' // The URI here is an example only.
1131    ];
1132    let desFileUris: Array<string> = await phAccessHelper.requestPhotoUrisReadPermission(srcFileUris);
1133    console.info('requestPhotoUrisReadPermission success, data is ' + desFileUris);
1134  } catch (err) {
1135    console.error('requestPhotoUrisReadPermission failed, errCode is ' + err.code + ', errMsg is ' + err.message);
1136  }
1137}
1138```
1139
1140## PhotoAsset
1141
1142Provides APIs for encapsulating file asset attributes.
1143
1144### Properties
1145
1146**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1147
1148| Name                     | Type                    | Readable| Writable| Description                                                  |
1149| ------------------------- | ------------------------ | ---- | ---- | ------------------------------------------------------ |
1150| 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.        |
1151| photoType   | [PhotoType](#phototype) | Yes  | No  | Type of the file.                                              |
1152| displayName               | string                   | Yes  | No  | File name, including the file name extension, to display.                                |
1153
1154### get
1155
1156get(member: string): MemberType
1157
1158Obtains a **PhotoAsset** member parameter.
1159
1160**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1161
1162**Parameters**
1163
1164| Name     | Type                       | Mandatory  | Description   |
1165| -------- | ------------------------- | ---- | ----- |
1166| 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']**.|
1167
1168**Return value**
1169
1170| Type               | Description                             |
1171| ------------------- | --------------------------------- |
1172| [MemberType](#membertype) | **PhotoAsset** member parameter obtained.|
1173
1174**Error codes**
1175
1176For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1177
1178| ID| Error Message|
1179| -------- | ---------------------------------------- |
1180| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1181| 13900020     | Invalid argument.         |
1182| 14000014     | Member is not a valid PhotoKey.         |
1183
1184**Example**
1185
1186```ts
1187import { dataSharePredicates } from '@kit.ArkData';
1188
1189async function example() {
1190  console.info('photoAssetGetDemo');
1191  try {
1192    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1193    let fetchOption: photoAccessHelper.FetchOptions = {
1194      fetchColumns: ['title'],
1195      predicates: predicates
1196    };
1197    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1198    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1199    let title: photoAccessHelper.PhotoKeys = photoAccessHelper.PhotoKeys.TITLE;
1200    let photoAssetTitle: photoAccessHelper.MemberType = photoAsset.get(title.toString());
1201    console.info('photoAsset Get photoAssetTitle = ', photoAssetTitle);
1202  } catch (err) {
1203    console.error(`release failed. error: ${err.code}, ${err.message}`);
1204  }
1205}
1206```
1207
1208### set
1209
1210set(member: string, value: string): void
1211
1212Sets a **PhotoAsset** member parameter.
1213
1214**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1215
1216**Parameters**
1217
1218| Name     | Type                       | Mandatory  | Description   |
1219| -------- | ------------------------- | ---- | ----- |
1220| member | string | Yes   | Name of the member parameter to set. For example, **[PhotoKeys](#photokeys).TITLE**.|
1221| value | string | Yes   | Member parameter to set. Only the value of **[PhotoKeys](#photokeys).TITLE** can be modified.|
1222
1223**Error codes**
1224
1225For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1226
1227| ID| Error Message|
1228| -------- | ---------------------------------------- |
1229| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1230| 13900020     | Invalid argument.         |
1231| 14000014     | Member is not a valid PhotoKey.         |
1232
1233**Example**
1234
1235```ts
1236import { dataSharePredicates } from '@kit.ArkData';
1237
1238async function example() {
1239  console.info('photoAssetSetDemo');
1240  try {
1241    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1242    let fetchOption: photoAccessHelper.FetchOptions = {
1243      fetchColumns: ['title'],
1244      predicates: predicates
1245    };
1246    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1247    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1248    let title: string = photoAccessHelper.PhotoKeys.TITLE.toString();
1249    photoAsset.set(title, 'newTitle');
1250  } catch (err) {
1251    console.error(`release failed. error: ${err.code}, ${err.message}`);
1252  }
1253}
1254```
1255
1256### commitModify
1257
1258commitModify(callback: AsyncCallback&lt;void&gt;): void
1259
1260Commits the modification on the file metadata to the database. This API uses an asynchronous callback to return the result.
1261
1262**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
1263
1264**Atomic service API**: This API can be used in atomic services since API version 11.
1265
1266**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1267
1268**Parameters**
1269
1270| Name     | Type                       | Mandatory  | Description   |
1271| -------- | ------------------------- | ---- | ----- |
1272| callback | AsyncCallback&lt;void&gt; | Yes   | Callback that returns no value.|
1273
1274**Error codes**
1275
1276For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1277
1278| ID| Error Message|
1279| -------- | ---------------------------------------- |
1280| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1281| 13900012     | Permission denied.         |
1282| 13900020     | Invalid argument.         |
1283| 14000001      | Invalid display name.         |
1284| 14000011       | System inner fail.         |
1285
1286**Example**
1287
1288```ts
1289import { dataSharePredicates } from '@kit.ArkData';
1290
1291async function example() {
1292  console.info('commitModifyDemo');
1293  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1294  let fetchOption: photoAccessHelper.FetchOptions = {
1295    fetchColumns: ['title'],
1296    predicates: predicates
1297  };
1298  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1299  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1300  let title: string = photoAccessHelper.PhotoKeys.TITLE.toString();
1301  let photoAssetTitle: photoAccessHelper.MemberType = photoAsset.get(title);
1302  console.info('photoAsset get photoAssetTitle = ', photoAssetTitle);
1303  photoAsset.set(title, 'newTitle2');
1304  photoAsset.commitModify((err) => {
1305    if (err === undefined) {
1306      let newPhotoAssetTitle: photoAccessHelper.MemberType = photoAsset.get(title);
1307      console.info('photoAsset get newPhotoAssetTitle = ', newPhotoAssetTitle);
1308    } else {
1309      console.error(`commitModify failed, error: ${err.code}, ${err.message}`);
1310    }
1311  });
1312}
1313```
1314
1315### commitModify
1316
1317commitModify(): Promise&lt;void&gt;
1318
1319Commits the modification on the file metadata to the database. This API uses a promise to return the result.
1320
1321**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
1322
1323**Atomic service API**: This API can be used in atomic services since API version 11.
1324
1325**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1326
1327**Return value**
1328
1329| Type                 | Description        |
1330| ------------------- | ---------- |
1331| Promise&lt;void&gt; | Promise that returns no value.|
1332
1333**Error codes**
1334
1335For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1336
1337| ID| Error Message|
1338| -------- | ---------------------------------------- |
1339| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1340| 13900012     | Permission denied.         |
1341| 13900020     | Invalid argument.         |
1342| 14000001      | Invalid display name.         |
1343| 14000011       | System inner fail.         |
1344
1345**Example**
1346
1347```ts
1348import { dataSharePredicates } from '@kit.ArkData';
1349
1350async function example() {
1351  console.info('commitModifyDemo');
1352  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1353  let fetchOption: photoAccessHelper.FetchOptions = {
1354    fetchColumns: ['title'],
1355    predicates: predicates
1356  };
1357  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1358  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1359  let title: string = photoAccessHelper.PhotoKeys.TITLE.toString();
1360  let photoAssetTitle: photoAccessHelper.MemberType = photoAsset.get(title);
1361  console.info('photoAsset get photoAssetTitle = ', photoAssetTitle);
1362  photoAsset.set(title, 'newTitle3');
1363  try {
1364    await photoAsset.commitModify();
1365    let newPhotoAssetTitle: photoAccessHelper.MemberType = photoAsset.get(title);
1366    console.info('photoAsset get newPhotoAssetTitle = ', newPhotoAssetTitle);
1367  } catch (err) {
1368    console.error(`release failed. error: ${err.code}, ${err.message}`);
1369  }
1370}
1371```
1372
1373### getReadOnlyFd<sup>(deprecated)</sup>
1374
1375getReadOnlyFd(callback: AsyncCallback&lt;number&gt;): void
1376
1377Opens this file in read-only mode. This API uses an asynchronous callback to return the result.
1378
1379> **NOTE**
1380>
1381> - 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.
1382
1383> - The returned FD must be closed when it is not required.
1384
1385**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1386
1387**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1388
1389**Parameters**
1390
1391| Name     | Type                         | Mandatory  | Description                                 |
1392| -------- | --------------------------- | ---- | ----------------------------------- |
1393| callback | AsyncCallback&lt;number&gt; | Yes   | Callback used to return the file descriptor (FD) of the file opened.                           |
1394
1395**Error codes**
1396
1397For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1398
1399| ID| Error Message|
1400| -------- | ---------------------------------------- |
1401| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1402| 13900012     | Permission denied.         |
1403| 13900020     | Invalid argument.         |
1404| 14000011       | System inner fail.         |
1405
1406**Example**
1407
1408```ts
1409async function example() {
1410  console.info('getReadOnlyFdDemo');
1411  // Ensure that there are images and video files in the device.
1412  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1413  let fetchOptions: photoAccessHelper.FetchOptions = {
1414    fetchColumns: [],
1415    predicates: predicates
1416  };
1417  let assetResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1418  let photoAsset: photoAccessHelper.PhotoAsset = await assetResult.getFirstObject();
1419  photoAsset.getReadOnlyFd((err, fd) => {
1420    if (fd !== undefined) {
1421      console.info('File fd' + fd);
1422      photoAsset.close(fd);
1423    } else {
1424      console.error(`getReadOnlyFd err: ${err.code}, ${err.message}`);
1425    }
1426  });
1427}
1428```
1429
1430### getReadOnlyFd<sup>(deprecated)</sup>
1431
1432getReadOnlyFd(): Promise&lt;number&gt;
1433
1434Opens this file in read-only mode. This API uses a promise to return the result.
1435
1436> **NOTE**
1437>
1438> - 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.
1439
1440> - The returned FD must be closed when it is not required.
1441
1442**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1443
1444**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1445
1446**Return value**
1447
1448| Type                   | Description           |
1449| --------------------- | ------------- |
1450| Promise&lt;number&gt; | Promise used to return the FD of the file opened.|
1451
1452**Error codes**
1453
1454For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1455
1456| ID| Error Message|
1457| -------- | ---------------------------------------- |
1458| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1459| 13900012     | Permission denied.         |
1460| 13900020     | Invalid argument.         |
1461| 14000011       | System inner fail.         |
1462
1463**Example**
1464
1465```ts
1466async function example() {
1467  console.info('getReadOnlyFdDemo');
1468  try {
1469    // Ensure that there are images and video files in the device.
1470    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1471    let fetchOptions: photoAccessHelper.FetchOptions = {
1472      fetchColumns: [],
1473      predicates: predicates
1474    };
1475    let assetResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1476    let photoAsset: photoAccessHelper.PhotoAsset = await assetResult.getFirstObject();
1477    let fd: number = await photoAsset.getReadOnlyFd();
1478    if (fd !== undefined) {
1479      console.info('File fd' + fd);
1480      photoAsset.close(fd);
1481    } else {
1482      console.error('getReadOnlyFd fail');
1483    }
1484  } catch (err) {
1485    console.error(`getReadOnlyFd demo err: ${err.code}, ${err.message}`);
1486  }
1487}
1488```
1489
1490### close<sup>(deprecated)</sup>
1491
1492close(fd: number, callback: AsyncCallback&lt;void&gt;): void
1493
1494Closes a file. This API uses an asynchronous callback to return the result.
1495
1496> **NOTE**
1497>
1498> - This API is supported since API version 10 and deprecated since API version 11.
1499> - For security purposes, the API for obtaining the media file handle is no longer provided, and the corresponding **close** API is also deprecated.
1500
1501**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1502
1503**Parameters**
1504
1505| Name     | Type                       | Mandatory  | Description   |
1506| -------- | ------------------------- | ---- | ----- |
1507| fd       | number                    | Yes   | FD of the file to close.|
1508| callback | AsyncCallback&lt;void&gt; | Yes   | Callback that returns no value.|
1509
1510**Error codes**
1511
1512For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1513
1514| ID| Error Message|
1515| -------- | ---------------------------------------- |
1516| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1517| 13900020     | Invalid argument.         |
1518| 14000011       | System inner fail.         |
1519
1520**Example**
1521
1522```ts
1523import { dataSharePredicates } from '@kit.ArkData';
1524
1525async function example() {
1526  console.info('closeDemo');
1527  try {
1528    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1529    let fetchOption: photoAccessHelper.FetchOptions = {
1530      fetchColumns: [],
1531      predicates: predicates
1532    };
1533    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1534    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1535    let fd: number = await photoAsset.open('rw');
1536    console.info('file fd', fd);
1537    photoAsset.close(fd, (err) => {
1538      if (err === undefined) {
1539        console.info('asset close succeed.');
1540      } else {
1541        console.error(`close failed, error: ${err.code}, ${err.message}`);
1542      }
1543    });
1544  } catch (err) {
1545    console.error(`close failed, error: ${err.code}, ${err.message}`);
1546  }
1547}
1548```
1549
1550### close<sup>(deprecated)</sup>
1551
1552close(fd: number): Promise&lt;void&gt;
1553
1554Closes a file. This API uses a promise to return the result.
1555
1556> **NOTE**
1557>
1558> 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.
1559
1560**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1561
1562**Parameters**
1563
1564| Name | Type    | Mandatory  | Description   |
1565| ---- | ------ | ---- | ----- |
1566| fd   | number | Yes   | FD of the file to close.|
1567
1568**Return value**
1569
1570| Type                 | Description        |
1571| ------------------- | ---------- |
1572| Promise&lt;void&gt; | Promise that returns no value.|
1573
1574**Error codes**
1575
1576For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1577
1578| ID| Error Message|
1579| -------- | ---------------------------------------- |
1580| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1581| 13900020     | Invalid argument.         |
1582| 14000011       | System inner fail.         |
1583
1584**Example**
1585
1586```ts
1587import { dataSharePredicates } from '@kit.ArkData';
1588
1589async function example() {
1590  console.info('closeDemo');
1591  try {
1592    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1593    let fetchOption: photoAccessHelper.FetchOptions = {
1594      fetchColumns: [],
1595      predicates: predicates
1596    };
1597    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1598    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1599    let fd = await asset.open('rw');
1600    console.info('file fd', fd);
1601    await asset.close(fd);
1602    console.info('asset close succeed.');
1603  } catch (err) {
1604    console.error(`close failed, error: ${err.code}, ${err.message}`);
1605  }
1606}
1607```
1608
1609### getThumbnail
1610
1611getThumbnail(callback: AsyncCallback&lt;image.PixelMap&gt;): void
1612
1613Obtains the thumbnail of this file. This API uses an asynchronous callback to return the result.
1614
1615**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1616
1617**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1618
1619**Parameters**
1620
1621| Name     | Type                                 | Mandatory  | Description              |
1622| -------- | ----------------------------------- | ---- | ---------------- |
1623| callback | AsyncCallback&lt;[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)&gt; | Yes   | Callback used to return the PixelMap of the thumbnail.|
1624
1625**Error codes**
1626
1627For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1628
1629| ID| Error Message|
1630| -------- | ---------------------------------------- |
1631| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1632| 13900012     | Permission denied.         |
1633| 13900020     | Invalid argument.         |
1634| 14000011       | System inner fail.         |
1635
1636**Example**
1637
1638```ts
1639import { dataSharePredicates } from '@kit.ArkData';
1640
1641async function example() {
1642  console.info('getThumbnailDemo');
1643  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1644  let fetchOption: photoAccessHelper.FetchOptions = {
1645    fetchColumns: [],
1646    predicates: predicates
1647  };
1648  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1649  let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1650  console.info('asset displayName = ', asset.displayName);
1651  asset.getThumbnail((err, pixelMap) => {
1652    if (err === undefined) {
1653      console.info('getThumbnail successful ' + pixelMap);
1654    } else {
1655      console.error(`getThumbnail fail with error: ${err.code}, ${err.message}`);
1656    }
1657  });
1658}
1659```
1660
1661### getThumbnail
1662
1663getThumbnail(size: image.Size, callback: AsyncCallback&lt;image.PixelMap&gt;): void
1664
1665Obtains the file thumbnail of the given size. This API uses an asynchronous callback to return the result.
1666
1667**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1668
1669**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1670
1671**Parameters**
1672
1673| Name     | Type                                 | Mandatory  | Description              |
1674| -------- | ----------------------------------- | ---- | ---------------- |
1675| size     | [image.Size](../apis-image-kit/js-apis-image.md#size) | Yes   | Size of the thumbnail.           |
1676| callback | AsyncCallback&lt;[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)&gt; | Yes   | Callback used to return the PixelMap of the thumbnail.|
1677
1678**Error codes**
1679
1680For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1681
1682| ID| Error Message|
1683| -------- | ---------------------------------------- |
1684| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1685| 13900012     | Permission denied.         |
1686| 13900020     | Invalid argument.         |
1687| 14000011       | System inner fail.         |
1688
1689**Example**
1690
1691```ts
1692import { dataSharePredicates } from '@kit.ArkData';
1693import { image } from '@kit.ImageKit';
1694
1695async function example() {
1696  console.info('getThumbnailDemo');
1697  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1698  let fetchOption: photoAccessHelper.FetchOptions = {
1699    fetchColumns: [],
1700    predicates: predicates
1701  };
1702  let size: image.Size = { width: 720, height: 720 };
1703  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1704  let asset = await fetchResult.getFirstObject();
1705  console.info('asset displayName = ', asset.displayName);
1706  asset.getThumbnail(size, (err, pixelMap) => {
1707    if (err === undefined) {
1708      console.info('getThumbnail successful ' + pixelMap);
1709    } else {
1710      console.error(`getThumbnail fail with error: ${err.code}, ${err.message}`);
1711    }
1712  });
1713}
1714```
1715
1716### getThumbnail
1717
1718getThumbnail(size?: image.Size): Promise&lt;image.PixelMap&gt;
1719
1720Obtains the file thumbnail of the given size. This API uses a promise to return the result.
1721
1722**Required permissions**: ohos.permission.READ_IMAGEVIDEO
1723
1724**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1725
1726**Parameters**
1727
1728| Name | Type            | Mandatory  | Description   |
1729| ---- | -------------- | ---- | ----- |
1730| size | [image.Size](../apis-image-kit/js-apis-image.md#size) | No   | Size of the thumbnail.|
1731
1732**Return value**
1733
1734| Type                           | Description                   |
1735| ----------------------------- | --------------------- |
1736| Promise&lt;[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)&gt; | Promise used to return the PixelMap of the thumbnail.|
1737
1738**Error codes**
1739
1740For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1741
1742| ID| Error Message|
1743| -------- | ---------------------------------------- |
1744| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1745| 13900012     | Permission denied.         |
1746| 13900020     | Invalid argument.         |
1747| 14000011       | System inner fail.         |
1748
1749**Example**
1750
1751```ts
1752import { dataSharePredicates } from '@kit.ArkData';
1753import { image } from '@kit.ImageKit';
1754import { BusinessError } from '@kit.BasicServicesKit';
1755
1756async function example() {
1757  console.info('getThumbnailDemo');
1758  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1759  let fetchOption: photoAccessHelper.FetchOptions = {
1760    fetchColumns: [],
1761    predicates: predicates
1762  };
1763  let size: image.Size = { width: 720, height: 720 };
1764  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1765  let asset = await fetchResult.getFirstObject();
1766  console.info('asset displayName = ', asset.displayName);
1767  asset.getThumbnail(size).then((pixelMap) => {
1768    console.info('getThumbnail successful ' + pixelMap);
1769  }).catch((err: BusinessError) => {
1770    console.error(`getThumbnail fail with error: ${err.code}, ${err.message}`);
1771  });
1772}
1773```
1774
1775### clone<sup>14+</sup>
1776
1777clone(title: string): Promise&lt;PhotoAsset&gt;
1778
1779Clones a media asset. The file name can be set, but the file type cannot be changed.
1780
1781**Required permissions**: ohos.permission.WRITE\_IMAGEVIDEO
1782
1783**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1784
1785**Parameters**
1786
1787| Name       | Type     | Mandatory  | Description                                |
1788| ---------- | ------- | ---- | ---------------------------------- |
1789| 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:\ / : * ? " ' ` < > \| { } [ ] |
1790
1791**Return value**
1792
1793| Type               | Description                   |
1794| ------------------- | ----------------------- |
1795| Promise&lt;PhotoAsset&gt; | Promise used to return the [PhotoAsset](#photoasset) cloned.|
1796
1797**Error codes**
1798
1799For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1800
1801| ID   | Error Message                             |
1802| :------- | :-------------------------------- |
1803| 201 | Permission denied. |
1804| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1805| 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. |
1806
1807**Example**
1808
1809```ts
1810import { dataSharePredicates } from '@kit.ArkData';
1811import { systemDateTime } from '@kit.BasicServicesKit';
1812
1813async function example() {
1814  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1815  let fetchOptions: photoAccessHelper.FetchOptions = {
1816    fetchColumns: [],
1817    predicates: predicates
1818  };
1819  try {
1820    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1821    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1822    let title: string = systemDateTime.getTime().toString();
1823    let newAsset: photoAccessHelper.PhotoAsset = await photoAsset.clone(title);
1824    console.info('get new asset successfully');
1825  } catch (error) {
1826    console.error(`failed to get new asset. message =  ${error.code}, ${error.message}`);
1827  }
1828}
1829```
1830
1831## PhotoViewPicker
1832
1833Provides APIs for the user to select images and videos. Before using the APIs of **PhotoViewPicker**, you need to create a **PhotoViewPicker** instance.
1834
1835**Atomic service API**: This API can be used in atomic services since API version 11.
1836
1837**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1838
1839**Example**
1840
1841```ts
1842let photoPicker = new photoAccessHelper.PhotoViewPicker();
1843```
1844
1845### select
1846
1847select(option?: PhotoSelectOptions) : Promise&lt;PhotoSelectResult&gt;
1848
1849Starts 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.
1850
1851**NOTE**<br>The **photoUris** in the **PhotoSelectResult** object returned by this API can be used only by calling [photoAccessHelper.getAssets()](#getassets) with temporary authorization. For details, see [Using a Media File URI](../../file-management/user-file-uri-intro.md#using-a-media-file-uri).
1852
1853**Atomic service API**: This API can be used in atomic services since API version 11.
1854
1855**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1856
1857**Parameters**
1858
1859| Name | Type   | Mandatory| Description                      |
1860| ------- | ------- | ---- | -------------------------- |
1861| option | [PhotoSelectOptions](#photoselectoptions) | No  | Options for selecting files. If this parameter is not specified, up to 50 images and videos are selected by default.|
1862
1863**Return value**
1864
1865| Type                           | Description   |
1866| ----------------------------- | :---- |
1867| Promise&lt;[PhotoSelectResult](#photoselectresult)&gt; | Promise return information about the images or videos selected.|
1868
1869**Error codes**
1870
1871For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1872
1873| ID| Error Message|
1874| -------- | ---------------------------------------- |
1875| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1876| 13900042      | Unknown error.         |
1877
1878**Example**
1879
1880```ts
1881import { BusinessError } from '@kit.BasicServicesKit';
1882async function example01() {
1883  try {
1884    let PhotoSelectOptions = new photoAccessHelper.PhotoSelectOptions();
1885    PhotoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE;
1886    PhotoSelectOptions.maxSelectNumber = 5;
1887    let photoPicker = new photoAccessHelper.PhotoViewPicker();
1888    photoPicker.select(PhotoSelectOptions).then((PhotoSelectResult: photoAccessHelper.PhotoSelectResult) => {
1889      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
1890    }).catch((err: BusinessError) => {
1891      console.error(`PhotoViewPicker.select failed with err: ${err.code}, ${err.message}`);
1892    });
1893  } catch (error) {
1894    let err: BusinessError = error as BusinessError;
1895    console.error(`PhotoViewPicker failed with err: ${err.code}, ${err.message}`);
1896  }
1897}
1898```
1899
1900### select
1901
1902select(option: PhotoSelectOptions, callback: AsyncCallback&lt;PhotoSelectResult&gt;) : void
1903
1904Starts 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.
1905
1906**NOTE**<br>The **photoUris** in the **PhotoSelectResult** object returned by this API can be used only by calling [photoAccessHelper.getAssets()](#getassets) with temporary authorization. For details, see [Using a Media File URI](../../file-management/user-file-uri-intro.md#using-a-media-file-uri).
1907
1908**Atomic service API**: This API can be used in atomic services since API version 11.
1909
1910**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1911
1912**Parameters**
1913
1914| Name | Type   | Mandatory| Description                      |
1915| ------- | ------- | ---- | -------------------------- |
1916| option | [PhotoSelectOptions](#photoselectoptions) | Yes  | Options for selecting images or videos.|
1917| callback | AsyncCallback&lt;[PhotoSelectResult](#photoselectresult)&gt;      | Yes  | Callback used to return information about the images or videos selected.|
1918
1919**Error codes**
1920
1921For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1922
1923| ID| Error Message|
1924| -------- | ---------------------------------------- |
1925| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1926| 13900042      | Unknown error.         |
1927
1928**Example**
1929
1930```ts
1931import { BusinessError } from '@kit.BasicServicesKit';
1932async function example02() {
1933  try {
1934    let PhotoSelectOptions = new photoAccessHelper.PhotoSelectOptions();
1935    PhotoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE;
1936    PhotoSelectOptions.maxSelectNumber = 5;
1937    let photoPicker = new photoAccessHelper.PhotoViewPicker();
1938    photoPicker.select(PhotoSelectOptions, (err: BusinessError, PhotoSelectResult: photoAccessHelper.PhotoSelectResult) => {
1939      if (err) {
1940        console.error(`PhotoViewPicker.select failed with err: ${err.code}, ${err.message}`);
1941        return;
1942      }
1943      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
1944    });
1945  } catch (error) {
1946    let err: BusinessError = error as BusinessError;
1947    console.error(`PhotoViewPicker failed with err: ${err.code}, ${err.message}`);
1948  }
1949}
1950```
1951
1952### select
1953
1954select(callback: AsyncCallback&lt;PhotoSelectResult&gt;) : void
1955
1956Starts a **photoPicker** page for the user to select one or more images or videos. This API uses an asynchronous callback to return the result.
1957
1958**NOTE**<br>The **photoUris** in the **PhotoSelectResult** object returned by this API can be used only by calling [photoAccessHelper.getAssets()](#getassets) with temporary authorization. For details, see [Using a Media File URI](../../file-management/user-file-uri-intro.md#using-a-media-file-uri).
1959
1960**Atomic service API**: This API can be used in atomic services since API version 11.
1961
1962**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
1963
1964**Parameters**
1965
1966| Name | Type   | Mandatory| Description                      |
1967| ------- | ------- | ---- | -------------------------- |
1968| callback | AsyncCallback&lt;[PhotoSelectResult](#photoselectresult)&gt;      | Yes  | Callback used to return information about the images or videos selected.|
1969
1970**Error codes**
1971
1972For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
1973
1974| ID| Error Message|
1975| -------- | ---------------------------------------- |
1976| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1977| 13900042      | Unknown error.         |
1978
1979**Example**
1980
1981```ts
1982import { BusinessError } from '@kit.BasicServicesKit';
1983async function example03() {
1984  try {
1985    let photoPicker = new photoAccessHelper.PhotoViewPicker();
1986    photoPicker.select((err: BusinessError, PhotoSelectResult: photoAccessHelper.PhotoSelectResult) => {
1987      if (err) {
1988        console.error(`PhotoViewPicker.select failed with err: ${err.code}, ${err.message}`);
1989        return;
1990      }
1991      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
1992    });
1993  } catch (error) {
1994    let err: BusinessError = error as BusinessError;
1995    console.error(`PhotoViewPicker failed with err: ${err.code}, ${err.message}`);
1996  }
1997}
1998```
1999
2000## FetchResult
2001
2002Provides APIs to manage the file retrieval result.
2003
2004### getCount
2005
2006getCount(): number
2007
2008Obtains the total number of files in the result set.
2009
2010**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2011
2012**Return value**
2013
2014| Type    | Description      |
2015| ------ | -------- |
2016| number | Returns the total number of files obtained.|
2017
2018**Error codes**
2019
2020For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2021
2022| ID| Error Message|
2023| -------- | ---------------------------------------- |
2024| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2025| 13900020     | Invalid argument.         |
2026| 14000011       | System inner fail.         |
2027
2028**Example**
2029
2030```ts
2031import { dataSharePredicates } from '@kit.ArkData';
2032
2033async function example() {
2034  console.info('getCountDemo');
2035  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2036  let fetchOption: photoAccessHelper.FetchOptions = {
2037    fetchColumns: [],
2038    predicates: predicates
2039  };
2040  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2041  let fetchCount = fetchResult.getCount();
2042  console.info('fetchCount = ', fetchCount);
2043}
2044```
2045
2046### isAfterLast
2047
2048isAfterLast(): boolean
2049
2050Checks whether the cursor is in the last row of the result set.
2051
2052**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2053
2054**Return value**
2055
2056| Type     | Description                                |
2057| ------- | ---------------------------------- |
2058| boolean | Returns **true** if the cursor is in the last row of the result set; returns **false** otherwise.|
2059
2060**Error codes**
2061
2062For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2063
2064| ID| Error Message|
2065| -------- | ---------------------------------------- |
2066| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2067| 13900020     | Invalid argument.         |
2068| 14000011       | System inner fail.         |
2069
2070**Example**
2071
2072```ts
2073import { dataSharePredicates } from '@kit.ArkData';
2074
2075async function example() {
2076  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2077  let fetchOption: photoAccessHelper.FetchOptions = {
2078    fetchColumns: [],
2079    predicates: predicates
2080  };
2081  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2082  let fetchCount = fetchResult.getCount();
2083  console.info('count:' + fetchCount);
2084  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getLastObject();
2085  if (fetchResult.isAfterLast()) {
2086    console.info('photoAsset isAfterLast displayName = ', photoAsset.displayName);
2087  } else {
2088    console.info('photoAsset not isAfterLast.');
2089  }
2090}
2091```
2092
2093### close
2094
2095close(): void
2096
2097Closes this **FetchFileResult** instance to invalidate it. After this instance is released, the APIs in this instance cannot be invoked.
2098
2099**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2100
2101**Error codes**
2102
2103For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2104
2105| ID| Error Message|
2106| -------- | ---------------------------------------- |
2107| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2108| 13900020     | Invalid argument.         |
2109| 14000011       | System inner fail.         |
2110
2111**Example**
2112
2113```ts
2114import { dataSharePredicates } from '@kit.ArkData';
2115
2116async function example() {
2117  console.info('fetchResultCloseDemo');
2118  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2119  let fetchOption: photoAccessHelper.FetchOptions = {
2120    fetchColumns: [],
2121    predicates: predicates
2122  };
2123  try {
2124    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2125    fetchResult.close();
2126    console.info('close succeed.');
2127  } catch (err) {
2128    console.error(`close fail. error: ${err.code}, ${err.message}`);
2129  }
2130}
2131```
2132
2133### getFirstObject
2134
2135getFirstObject(callback: AsyncCallback&lt;T&gt;): void
2136
2137Obtains the first file asset in the result set. This API uses an asynchronous callback to return the result.
2138
2139**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2140
2141**Parameters**
2142
2143| Name  | Type                                         | Mandatory| Description                                       |
2144| -------- | --------------------------------------------- | ---- | ------------------------------------------- |
2145| callback | AsyncCallback&lt;T&gt; | Yes  | Callback used to return the first file asset obtained.|
2146
2147**Error codes**
2148
2149For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2150
2151| ID| Error Message|
2152| -------- | ---------------------------------------- |
2153| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2154| 13900020     | Invalid argument.         |
2155| 14000011       | System inner fail.         |
2156
2157**Example**
2158
2159```ts
2160import { dataSharePredicates } from '@kit.ArkData';
2161
2162async function example() {
2163  console.info('getFirstObjectDemo');
2164  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2165  let fetchOption: photoAccessHelper.FetchOptions = {
2166    fetchColumns: [],
2167    predicates: predicates
2168  };
2169  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2170  fetchResult.getFirstObject((err, photoAsset) => {
2171    if (photoAsset !== undefined) {
2172      console.info('photoAsset displayName: ', photoAsset.displayName);
2173    } else {
2174      console.error(`photoAsset failed with err:${err.code}, ${err.message}`);
2175    }
2176  });
2177}
2178```
2179
2180### getFirstObject
2181
2182getFirstObject(): Promise&lt;T&gt;
2183
2184Obtains the first file asset in the result set. This API uses a promise to return the result.
2185
2186**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2187
2188**Return value**
2189
2190| Type                                   | Description                      |
2191| --------------------------------------- | -------------------------- |
2192| Promise&lt;T&gt; | Promise used to return the first object in the result set.|
2193
2194**Error codes**
2195
2196For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2197
2198| ID| Error Message|
2199| -------- | ---------------------------------------- |
2200| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2201| 13900020     | Invalid argument.         |
2202| 14000011       | System inner fail.         |
2203
2204**Example**
2205
2206```ts
2207import { dataSharePredicates } from '@kit.ArkData';
2208
2209async function example() {
2210  console.info('getFirstObjectDemo');
2211  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2212  let fetchOption: photoAccessHelper.FetchOptions = {
2213    fetchColumns: [],
2214    predicates: predicates
2215  };
2216  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2217  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2218  console.info('photoAsset displayName: ', photoAsset.displayName);
2219}
2220```
2221
2222### getNextObject
2223
2224getNextObject(callback: AsyncCallback&lt;T&gt;): void
2225
2226Obtains the next file asset in the result set. This API uses an asynchronous callback to return the result.
2227Before using this API, you must use [isAfterLast()](#isafterlast) to check whether the current position is the end of the result set.
2228
2229**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2230
2231**Parameters**
2232
2233| Name   | Type                                         | Mandatory| Description                                     |
2234| --------- | --------------------------------------------- | ---- | ----------------------------------------- |
2235| callback | AsyncCallback&lt;T&gt; | Yes  | Callback used to return the next file asset.|
2236
2237**Error codes**
2238
2239For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2240
2241| ID| Error Message|
2242| -------- | ---------------------------------------- |
2243| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2244| 13900020     | Invalid argument.         |
2245| 14000011       | System inner fail.         |
2246
2247**Example**
2248
2249```ts
2250import { dataSharePredicates } from '@kit.ArkData';
2251
2252async function example() {
2253  console.info('getNextObjectDemo');
2254  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2255  let fetchOption: photoAccessHelper.FetchOptions = {
2256    fetchColumns: [],
2257    predicates: predicates
2258  };
2259  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2260  await fetchResult.getFirstObject();
2261  if (!fetchResult.isAfterLast()) {
2262    fetchResult.getNextObject((err, photoAsset) => {
2263      if (photoAsset !== undefined) {
2264        console.info('photoAsset displayName: ', photoAsset.displayName);
2265      } else {
2266        console.error(`photoAsset failed with err: ${err.code}, ${err.message}`);
2267      }
2268    });
2269  }
2270}
2271```
2272
2273### getNextObject
2274
2275getNextObject(): Promise&lt;T&gt;
2276
2277Obtains the next file asset in the result set. This API uses a promise to return the result.
2278Before using this API, you must use [isAfterLast()](#isafterlast) to check whether the current position is the end of the result set.
2279
2280**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2281
2282**Return value**
2283
2284| Type                                   | Description             |
2285| --------------------------------------- | ----------------- |
2286| Promise&lt;T&gt; | Promise used to return the next object in the result set.|
2287
2288**Error codes**
2289
2290For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2291
2292| ID| Error Message|
2293| -------- | ---------------------------------------- |
2294| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2295| 13900020     | Invalid argument.         |
2296| 14000011       | System inner fail.         |
2297
2298**Example**
2299
2300```ts
2301import { dataSharePredicates } from '@kit.ArkData';
2302
2303async function example() {
2304  console.info('getNextObjectDemo');
2305  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2306  let fetchOption: photoAccessHelper.FetchOptions = {
2307    fetchColumns: [],
2308    predicates: predicates
2309  };
2310  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2311  await fetchResult.getFirstObject();
2312  if (!fetchResult.isAfterLast()) {
2313    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getNextObject();
2314    console.info('photoAsset displayName: ', photoAsset.displayName);
2315  }
2316}
2317```
2318
2319### getLastObject
2320
2321getLastObject(callback: AsyncCallback&lt;T&gt;): void
2322
2323Obtains the last file asset in the result set. This API uses an asynchronous callback to return the result.
2324
2325**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2326
2327**Parameters**
2328
2329| Name  | Type                                         | Mandatory| Description                       |
2330| -------- | --------------------------------------------- | ---- | --------------------------- |
2331| callback | AsyncCallback&lt;T&gt; | Yes  | Callback used to return the last file asset obtained.|
2332
2333**Error codes**
2334
2335For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2336
2337| ID| Error Message|
2338| -------- | ---------------------------------------- |
2339| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2340| 13900020     | Invalid argument.         |
2341| 14000011       | System inner fail.         |
2342
2343**Example**
2344
2345```ts
2346import { dataSharePredicates } from '@kit.ArkData';
2347
2348async function example() {
2349  console.info('getLastObjectDemo');
2350  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2351  let fetchOption: photoAccessHelper.FetchOptions = {
2352    fetchColumns: [],
2353    predicates: predicates
2354  };
2355  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2356  fetchResult.getLastObject((err, photoAsset) => {
2357    if (photoAsset !== undefined) {
2358      console.info('photoAsset displayName: ', photoAsset.displayName);
2359    } else {
2360      console.error(`photoAsset failed with err: ${err.code}, ${err.message}`);
2361    }
2362  });
2363}
2364```
2365
2366### getLastObject
2367
2368getLastObject(): Promise&lt;T&gt;
2369
2370Obtains the last file asset in the result set. This API uses a promise to return the result.
2371
2372**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2373
2374**Return value**
2375
2376| Type                                   | Description             |
2377| --------------------------------------- | ----------------- |
2378| Promise&lt;T&gt; | Promise used to return the last object in the result set.|
2379
2380**Error codes**
2381
2382For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2383
2384| ID| Error Message|
2385| -------- | ---------------------------------------- |
2386| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2387| 13900020     | Invalid argument.         |
2388| 14000011       | System inner fail.         |
2389
2390**Example**
2391
2392```ts
2393import { dataSharePredicates } from '@kit.ArkData';
2394
2395async function example() {
2396  console.info('getLastObjectDemo');
2397  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2398  let fetchOption: photoAccessHelper.FetchOptions = {
2399    fetchColumns: [],
2400    predicates: predicates
2401  };
2402  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2403  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getLastObject();
2404  console.info('photoAsset displayName: ', photoAsset.displayName);
2405}
2406```
2407
2408### getObjectByPosition
2409
2410getObjectByPosition(index: number, callback: AsyncCallback&lt;T&gt;): void
2411
2412Obtains a file asset with the specified index in the result set. This API uses an asynchronous callback to return the result.
2413
2414**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2415
2416**Parameters**
2417
2418| Name      | Type                                      | Mandatory  | Description                |
2419| -------- | ---------------------------------------- | ---- | ------------------ |
2420| index    | number                                   | Yes   | Index of the file asset to obtain. The value starts from **0**.    |
2421| callback | AsyncCallback&lt;T&gt; | Yes   | Callback used to return the file asset obtained.|
2422
2423**Error codes**
2424
2425For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2426
2427| ID| Error Message|
2428| -------- | ---------------------------------------- |
2429| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2430| 13900020     | Invalid argument.         |
2431| 14000011       | System inner fail.         |
2432
2433**Example**
2434
2435```ts
2436import { dataSharePredicates } from '@kit.ArkData';
2437
2438async function example() {
2439  console.info('getObjectByPositionDemo');
2440  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2441  let fetchOption: photoAccessHelper.FetchOptions = {
2442    fetchColumns: [],
2443    predicates: predicates
2444  };
2445  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2446  fetchResult.getObjectByPosition(0, (err, photoAsset) => {
2447    if (photoAsset !== undefined) {
2448      console.info('photoAsset displayName: ', photoAsset.displayName);
2449    } else {
2450      console.error(`photoAsset failed with err: ${err.code}, ${err.message}`);
2451    }
2452  });
2453}
2454```
2455
2456### getObjectByPosition
2457
2458getObjectByPosition(index: number): Promise&lt;T&gt;
2459
2460Obtains a file asset with the specified index in the result set. This API uses a promise to return the result.
2461
2462**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2463
2464**Parameters**
2465
2466| Name   | Type    | Mandatory  | Description            |
2467| ----- | ------ | ---- | -------------- |
2468| index | number | Yes   | Index of the file asset to obtain. The value starts from **0**.|
2469
2470**Return value**
2471
2472| Type                                   | Description             |
2473| --------------------------------------- | ----------------- |
2474| Promise&lt;T&gt; | Promise used to return the file asset obtained.|
2475
2476**Error codes**
2477
2478For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2479
2480| ID| Error Message|
2481| -------- | ---------------------------------------- |
2482| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2483| 13900020     | Invalid argument.         |
2484| 14000011       | System inner fail.         |
2485
2486**Example**
2487
2488```ts
2489import { dataSharePredicates } from '@kit.ArkData';
2490
2491async function example() {
2492  console.info('getObjectByPositionDemo');
2493  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2494  let fetchOption: photoAccessHelper.FetchOptions = {
2495    fetchColumns: [],
2496    predicates: predicates
2497  };
2498  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2499  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getObjectByPosition(0);
2500  console.info('photoAsset displayName: ', photoAsset.displayName);
2501}
2502```
2503
2504### getAllObjects
2505
2506getAllObjects(callback: AsyncCallback&lt;Array&lt;T&gt;&gt;): void
2507
2508Obtains all the file assets in the result set. This API uses an asynchronous callback to return the result.
2509
2510**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2511
2512**Parameters**
2513
2514| Name  | Type                                         | Mandatory| Description                                       |
2515| -------- | --------------------------------------------- | ---- | ------------------------------------------- |
2516| callback | AsyncCallback&lt;Array&lt;T&gt;&gt; | Yes  | Callback used to return an array of all file assets in the result set.|
2517
2518**Error codes**
2519
2520For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2521
2522| ID| Error Message|
2523| -------- | ---------------------------------------- |
2524| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2525| 13900020     | Invalid argument.         |
2526| 14000011       | System inner fail.         |
2527
2528**Example**
2529
2530```ts
2531import { dataSharePredicates } from '@kit.ArkData';
2532
2533async function example() {
2534  console.info('getAllObjectDemo');
2535  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2536  let fetchOption: photoAccessHelper.FetchOptions = {
2537    fetchColumns: [],
2538    predicates: predicates
2539  };
2540  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2541  fetchResult.getAllObjects((err, photoAssetList) => {
2542    if (photoAssetList !== undefined) {
2543      console.info('photoAssetList length: ', photoAssetList.length);
2544    } else {
2545      console.error(`photoAssetList failed with err:${err.code}, ${err.message}`);
2546    }
2547  });
2548}
2549```
2550
2551### getAllObjects
2552
2553getAllObjects(): Promise&lt;Array&lt;T&gt;&gt;
2554
2555Obtains all the file assets in the result set. This API uses a promise to return the result.
2556
2557**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2558
2559**Return value**
2560
2561| Type                                   | Description                      |
2562| --------------------------------------- | -------------------------- |
2563| Promise&lt;Array&lt;T&gt;&gt; | Promise used to return an array of all file assets in the result set.|
2564
2565**Error codes**
2566
2567For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2568
2569| ID| Error Message|
2570| -------- | ---------------------------------------- |
2571| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2572| 13900020     | Invalid argument.         |
2573| 14000011       | System inner fail.         |
2574
2575**Example**
2576
2577```ts
2578import { dataSharePredicates } from '@kit.ArkData';
2579
2580async function example() {
2581  console.info('getAllObjectDemo');
2582  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2583  let fetchOption: photoAccessHelper.FetchOptions = {
2584    fetchColumns: [],
2585    predicates: predicates
2586  };
2587  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2588  let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects();
2589  console.info('photoAssetList length: ', photoAssetList.length);
2590}
2591```
2592
2593## Album
2594
2595Provides APIs to manage albums.
2596
2597### Properties
2598
2599**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2600
2601| Name          | Type   | Readable  | Writable | Description  |
2602| ------------ | ------ | ---- | ---- | ------- |
2603| albumType | [AlbumType](#albumtype) | Yes   | No   | Type of the album.   |
2604| albumSubtype | [AlbumSubtype](#albumsubtype) | Yes   | No  | Subtype of the album.   |
2605| albumName | string | Yes   | Yes for a user album; no for a system album.  | Name of the album.   |
2606| albumUri | string | Yes   | No   | URI of the album.  |
2607| count | number | Yes   | No   |  Number of files in the album.|
2608| coverUri | string | Yes   | No   | URI of the cover file of the album.|
2609| imageCount<sup>11+</sup> | number | Yes  | No  | Number of images in the album.|
2610| videoCount<sup>11+</sup> | number | Yes  | No  | Number of videos in the album.|
2611
2612### getAssets
2613
2614getAssets(options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;PhotoAsset&gt;&gt;): void
2615
2616Obtains image and video assets. This API uses an asynchronous callback to return the result.
2617
2618**Required permissions**: ohos.permission.READ_IMAGEVIDEO
2619
2620**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2621
2622**Parameters**
2623
2624| Name  | Type                     | Mandatory| Description      |
2625| -------- | ------------------------- | ---- | ---------- |
2626| options | [FetchOptions](#fetchoptions) | Yes  | Options for fetching the assets.|
2627| callback | AsyncCallback&lt;[FetchResult](#fetchresult)&lt;[PhotoAsset](#photoasset)&gt;&gt; | Yes  | Callback used to return the image and video assets obtained.|
2628
2629**Error codes**
2630
2631For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2632
2633| ID| Error Message|
2634| -------- | ---------------------------------------- |
2635| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2636| 13900012     | Permission denied.         |
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('albumGetAssetsDemoCallback');
2647  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2648  let albumFetchOptions: photoAccessHelper.FetchOptions = {
2649    fetchColumns: [],
2650    predicates: predicates
2651  };
2652  let fetchOption: photoAccessHelper.FetchOptions = {
2653    fetchColumns: [],
2654    predicates: predicates
2655  };
2656  let albumList: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
2657  let album: photoAccessHelper.Album = await albumList.getFirstObject();
2658  album.getAssets(fetchOption, (err, albumFetchResult) => {
2659    if (albumFetchResult !== undefined) {
2660      console.info('album getAssets successfully, getCount: ' + albumFetchResult.getCount());
2661    } else {
2662      console.error(`album getAssets failed with error: ${err.code}, ${err.message}`);
2663    }
2664  });
2665}
2666```
2667
2668### getAssets
2669
2670getAssets(options: FetchOptions): Promise&lt;FetchResult&lt;PhotoAsset&gt;&gt;
2671
2672Obtains image and video assets. This API uses a promise to return the result.
2673
2674**Required permissions**: ohos.permission.READ_IMAGEVIDEO
2675
2676**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2677
2678**Parameters**
2679
2680| Name  | Type                     | Mandatory| Description      |
2681| -------- | ------------------------- | ---- | ---------- |
2682| options | [FetchOptions](#fetchoptions) | Yes  | Options for fetching the assets.|
2683
2684**Return value**
2685
2686| Type                                   | Description             |
2687| --------------------------------------- | ----------------- |
2688| Promise&lt;[FetchResult](#fetchresult)&lt;[PhotoAsset](#photoasset)&gt;&gt; | Promise used to return the image and video assets obtained.|
2689
2690**Error codes**
2691
2692For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2693
2694| ID| Error Message|
2695| -------- | ---------------------------------------- |
2696| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2697| 13900012     | Permission denied.         |
2698| 13900020     | Invalid argument.         |
2699| 14000011       | System inner fail.         |
2700
2701**Example**
2702
2703```ts
2704import { dataSharePredicates } from '@kit.ArkData';
2705import { BusinessError } from '@kit.BasicServicesKit';
2706
2707async function example() {
2708  console.info('albumGetAssetsDemoPromise');
2709  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2710  let albumFetchOptions: photoAccessHelper.FetchOptions = {
2711    fetchColumns: [],
2712    predicates: predicates
2713  };
2714  let fetchOption: photoAccessHelper.FetchOptions = {
2715    fetchColumns: [],
2716    predicates: predicates
2717  };
2718  let albumList: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
2719  let album: photoAccessHelper.Album = await albumList.getFirstObject();
2720  album.getAssets(fetchOption).then((albumFetchResult) => {
2721    console.info('album getAssets successfully, getCount: ' + albumFetchResult.getCount());
2722  }).catch((err: BusinessError) => {
2723    console.error(`album getAssets failed with error: ${err.code}, ${err.message}`);
2724  });
2725}
2726```
2727
2728### commitModify
2729
2730commitModify(callback: AsyncCallback&lt;void&gt;): void
2731
2732Commits the modification on the album attributes to the database. This API uses an asynchronous callback to return the result.
2733
2734**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
2735
2736**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2737
2738**Parameters**
2739
2740| Name  | Type                     | Mandatory| Description      |
2741| -------- | ------------------------- | ---- | ---------- |
2742| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
2743
2744**Error codes**
2745
2746For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2747
2748| ID| Error Message|
2749| -------- | ---------------------------------------- |
2750| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2751| 13900012     | Permission denied.         |
2752| 13900020     | Invalid argument.         |
2753| 14000011       | System inner fail.         |
2754
2755**Example**
2756
2757```ts
2758import { dataSharePredicates } from '@kit.ArkData';
2759
2760async function example() {
2761  console.info('albumCommitModifyDemo');
2762  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2763  let albumFetchOptions: photoAccessHelper.FetchOptions = {
2764    fetchColumns: [],
2765    predicates: predicates
2766  };
2767  let albumList: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
2768  let album: photoAccessHelper.Album = await albumList.getFirstObject();
2769  album.albumName = 'hello';
2770  album.commitModify((err) => {
2771    if (err !== undefined) {
2772      console.error(`commitModify failed with error: ${err.code}, ${err.message}`);
2773    } else {
2774      console.info('commitModify successfully');
2775    }
2776  });
2777}
2778```
2779
2780### commitModify
2781
2782commitModify(): Promise&lt;void&gt;
2783
2784Commits the modification on the album attributes to the database. This API uses a promise to return the result.
2785
2786**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
2787
2788**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2789
2790**Return value**
2791
2792| Type                 | Description          |
2793| ------------------- | ------------ |
2794| Promise&lt;void&gt; | Promise that returns no value.|
2795
2796**Error codes**
2797
2798For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2799
2800| ID| Error Message|
2801| -------- | ---------------------------------------- |
2802| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2803| 13900012     | Permission denied.         |
2804| 13900020     | Invalid argument.         |
2805| 14000011       | System inner fail.         |
2806
2807**Example**
2808
2809```ts
2810import { dataSharePredicates } from '@kit.ArkData';
2811import { BusinessError } from '@kit.BasicServicesKit';
2812
2813async function example() {
2814  console.info('albumCommitModifyDemo');
2815  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2816  let albumFetchOptions: photoAccessHelper.FetchOptions = {
2817    fetchColumns: [],
2818    predicates: predicates
2819  };
2820  let albumList: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions);
2821  let album: photoAccessHelper.Album = await albumList.getFirstObject();
2822  album.albumName = 'hello';
2823  album.commitModify().then(() => {
2824    console.info('commitModify successfully');
2825  }).catch((err: BusinessError) => {
2826    console.error(`commitModify failed with error: ${err.code}, ${err.message}`);
2827  });
2828}
2829```
2830
2831### addAssets<sup>(deprecated)</sup>
2832
2833addAssets(assets: Array&lt;PhotoAsset&gt;, callback: AsyncCallback&lt;void&gt;): void
2834
2835Adds 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.
2836
2837> **NOTE**
2838>
2839> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.addAssets](#addassets11) instead.
2840
2841**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
2842
2843**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2844
2845**Parameters**
2846
2847| Name  | Type                     | Mandatory| Description      |
2848| -------- | ------------------------- | ---- | ---------- |
2849| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Array of the image and video assets to add.|
2850| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
2851
2852**Error codes**
2853
2854For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2855
2856| ID| Error Message|
2857| -------- | ---------------------------------------- |
2858| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2859| 13900012     | Permission denied.         |
2860| 13900020     | Invalid argument.         |
2861| 14000011       | System inner fail.         |
2862
2863**Example**
2864
2865```ts
2866import { dataSharePredicates } from '@kit.ArkData';
2867
2868async function example() {
2869  try {
2870    console.info('addAssetsDemoCallback');
2871    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2872    let fetchOption: photoAccessHelper.FetchOptions = {
2873      fetchColumns: [],
2874      predicates: predicates
2875    };
2876    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
2877    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
2878    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2879    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2880    album.addAssets([asset], (err) => {
2881      if (err === undefined) {
2882        console.info('album addAssets successfully');
2883      } else {
2884        console.error(`album addAssets failed with error: ${err.code}, ${err.message}`);
2885      }
2886    });
2887  } catch (err) {
2888    console.error(`addAssetsDemoCallback failed with error: ${err.code}, ${err.message}`);
2889  }
2890}
2891```
2892
2893### addAssets<sup>(deprecated)</sup>
2894
2895addAssets(assets: Array&lt;PhotoAsset&gt;): Promise&lt;void&gt;
2896
2897Adds 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.
2898
2899> **NOTE**
2900>
2901> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.addAssets](#addassets11) instead.
2902
2903**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
2904
2905**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2906
2907**Parameters**
2908
2909| Name  | Type                     | Mandatory| Description      |
2910| -------- | ------------------------- | ---- | ---------- |
2911| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Array of the image and video assets to add.|
2912
2913**Return value**
2914
2915| Type                                   | Description             |
2916| --------------------------------------- | ----------------- |
2917|Promise&lt;void&gt; | Promise that returns no value.|
2918
2919**Error codes**
2920
2921For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2922
2923| ID| Error Message|
2924| -------- | ---------------------------------------- |
2925| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2926| 13900012     | Permission denied.         |
2927| 13900020     | Invalid argument.         |
2928| 14000011       | System inner fail.         |
2929
2930**Example**
2931
2932```ts
2933import { dataSharePredicates } from '@kit.ArkData';
2934import { BusinessError } from '@kit.BasicServicesKit';
2935
2936async function example() {
2937  try {
2938    console.info('addAssetsDemoPromise');
2939    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2940    let fetchOption: photoAccessHelper.FetchOptions = {
2941      fetchColumns: [],
2942      predicates: predicates
2943    };
2944    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
2945    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
2946    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2947    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2948    album.addAssets([asset]).then(() => {
2949      console.info('album addAssets successfully');
2950    }).catch((err: BusinessError) => {
2951      console.error(`album addAssets failed with error: ${err.code}, ${err.message}`);
2952    });
2953  } catch (err) {
2954    console.error(`addAssetsDemoPromise failed with error: ${err.code}, ${err.message}`);
2955  }
2956}
2957```
2958
2959### removeAssets<sup>(deprecated)</sup>
2960
2961removeAssets(assets: Array&lt;PhotoAsset&gt;, callback: AsyncCallback&lt;void&gt;): void
2962
2963Removes image and video assets from an album. The album and file resources must exist. This API uses an asynchronous callback to return the result.
2964
2965> **NOTE**
2966>
2967> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.removeAssets](#removeassets11) instead.
2968
2969**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
2970
2971**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
2972
2973**Parameters**
2974
2975| Name  | Type                     | Mandatory| Description      |
2976| -------- | ------------------------- | ---- | ---------- |
2977| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Array of the image and video assets to remove.|
2978| callback | AsyncCallback&lt;void&gt; | Yes  | Callback that returns no value.|
2979
2980**Error codes**
2981
2982For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
2983
2984| ID| Error Message|
2985| -------- | ---------------------------------------- |
2986| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2987| 13900012     | Permission denied.         |
2988| 13900020     | Invalid argument.         |
2989| 14000011       | System inner fail.         |
2990
2991**Example**
2992
2993```ts
2994import { dataSharePredicates } from '@kit.ArkData';
2995
2996async function example() {
2997  try {
2998    console.info('removeAssetsDemoCallback');
2999    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3000    let fetchOption: photoAccessHelper.FetchOptions = {
3001      fetchColumns: [],
3002      predicates: predicates
3003    };
3004    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
3005    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
3006    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
3007    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3008    album.removeAssets([asset], (err) => {
3009      if (err === undefined) {
3010        console.info('album removeAssets successfully');
3011      } else {
3012        console.error(`album removeAssets failed with error: ${err.code}, ${err.message}`);
3013      }
3014    });
3015  } catch (err) {
3016    console.error(`removeAssetsDemoCallback failed with error: ${err.code}, ${err.message}`);
3017  }
3018}
3019```
3020
3021### removeAssets<sup>(deprecated)</sup>
3022
3023removeAssets(assets: Array&lt;PhotoAsset&gt;): Promise&lt;void&gt;
3024
3025Removes image and video assets from an album. The album and file resources must exist. This API uses a promise to return the result.
3026
3027> **NOTE**
3028>
3029> This API is supported since API version 10 and deprecated since API version 11. Use [MediaAlbumChangeRequest.removeAssets](#removeassets11) instead.
3030
3031**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3032
3033**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3034
3035**Parameters**
3036
3037| Name  | Type                     | Mandatory| Description      |
3038| -------- | ------------------------- | ---- | ---------- |
3039| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Array of the image and video assets to remove.|
3040
3041**Return value**
3042
3043| Type                                   | Description             |
3044| --------------------------------------- | ----------------- |
3045|Promise&lt;void&gt; | Promise that returns no value.|
3046
3047**Error codes**
3048
3049For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3050
3051| ID| Error Message|
3052| -------- | ---------------------------------------- |
3053| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3054| 13900012     | Permission denied.         |
3055| 13900020     | Invalid argument.         |
3056| 14000011       | System inner fail.         |
3057
3058**Example**
3059
3060```ts
3061import { dataSharePredicates } from '@kit.ArkData';
3062import { BusinessError } from '@kit.BasicServicesKit';
3063
3064async function example() {
3065  try {
3066    console.info('removeAssetsDemoPromise');
3067    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3068    let fetchOption: photoAccessHelper.FetchOptions = {
3069      fetchColumns: [],
3070      predicates: predicates
3071    };
3072    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
3073    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
3074    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
3075    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3076    album.removeAssets([asset]).then(() => {
3077      console.info('album removeAssets successfully');
3078    }).catch((err: BusinessError) => {
3079      console.error(`album removeAssets failed with error: ${err.code}, ${err.message}`);
3080    });
3081  } catch (err) {
3082    console.error(`removeAssetsDemoPromise failed with error: ${err.code}, ${err.message}`);
3083  }
3084}
3085```
3086
3087## MediaAssetChangeRequest<sup>11+</sup>
3088
3089Represents a media asset change request.
3090
3091**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3092
3093### constructor<sup>11+</sup>
3094
3095constructor(asset: PhotoAsset)
3096
3097Constructor.
3098
3099**Atomic service API**: This API can be used in atomic services since API version 12.
3100
3101**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3102
3103**Parameters**
3104
3105| Name  | Type                     | Mandatory| Description      |
3106| -------- | ------------------------- | ---- | ---------- |
3107| asset | [PhotoAsset](#photoasset) | Yes  | Assets to change.|
3108
3109**Error codes**
3110
3111For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3112
3113| ID| Error Message|
3114| -------- | ---------------------------------------- |
3115| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3116| 14000011       | System inner fail.          |
3117
3118**Example**
3119
3120```ts
3121import { dataSharePredicates } from '@kit.ArkData';
3122
3123async function example() {
3124  console.info('MediaAssetChangeRequest constructorDemo');
3125  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3126  let fetchOptions: photoAccessHelper.FetchOptions = {
3127    fetchColumns: [],
3128    predicates: predicates
3129  };
3130  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3131  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3132  let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(photoAsset);
3133}
3134```
3135
3136### createImageAssetRequest<sup>11+</sup>
3137
3138static createImageAssetRequest(context: Context, fileUri: string): MediaAssetChangeRequest
3139
3140Creates an image asset change request.
3141
3142Use **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).
3143
3144**Atomic service API**: This API can be used in atomic services since API version 12.
3145
3146**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3147
3148**Parameters**
3149
3150| Name | Type   | Mandatory| Description                      |
3151| ------- | ------- | ---- | -------------------------- |
3152| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
3153| fileUri | string | Yes  | Data source of the image asset, which is specified by a URI in the application sandbox directory.|
3154
3155**Return value**
3156
3157| Type                                   | Description             |
3158| --------------------------------------- | ----------------- |
3159| [MediaAssetChangeRequest](#mediaassetchangerequest11) | **MediaAssetChangeRequest** created.|
3160
3161**Error codes**
3162
3163For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3164
3165| ID| Error Message|
3166| -------- | ---------------------------------------- |
3167| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3168| 13900002   | No such file.         |
3169| 14000011   | System inner fail.        |
3170
3171**Example**
3172
3173```ts
3174async function example() {
3175  console.info('createImageAssetRequestDemo');
3176  try {
3177    // Ensure that the asset specified by fileUri exists.
3178    let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
3179    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createImageAssetRequest(context, fileUri);
3180    await phAccessHelper.applyChanges(assetChangeRequest);
3181    console.info('apply createImageAssetRequest successfully');
3182  } catch (err) {
3183    console.error(`createImageAssetRequestDemo failed with error: ${err.code}, ${err.message}`);
3184  }
3185}
3186```
3187
3188### createVideoAssetRequest<sup>11+</sup>
3189
3190static createVideoAssetRequest(context: Context, fileUri: string): MediaAssetChangeRequest
3191
3192Creates a video asset change request.
3193
3194Use **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).
3195
3196**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3197
3198**Parameters**
3199
3200| Name | Type   | Mandatory| Description                      |
3201| ------- | ------- | ---- | -------------------------- |
3202| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
3203| fileUri | string | Yes  | Data source of the video asset, which is specified by a URI in the application sandbox directory.|
3204
3205**Return value**
3206
3207| Type                                   | Description             |
3208| --------------------------------------- | ----------------- |
3209| [MediaAssetChangeRequest](#mediaassetchangerequest11) | **MediaAssetChangeRequest** created.|
3210
3211**Error codes**
3212
3213For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3214
3215| ID| Error Message|
3216| -------- | ---------------------------------------- |
3217| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3218| 13900002   | No such file.         |
3219| 14000011   | System inner fail.        |
3220
3221**Example**
3222
3223```ts
3224async function example() {
3225  console.info('createVideoAssetRequestDemo');
3226  try {
3227    // Ensure that the asset specified by fileUri exists.
3228    let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.mp4';
3229    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createVideoAssetRequest(context, fileUri);
3230    await phAccessHelper.applyChanges(assetChangeRequest);
3231    console.info('apply createVideoAssetRequest successfully');
3232  } catch (err) {
3233    console.error(`createVideoAssetRequestDemo failed with error: ${err.code}, ${err.message}`);
3234  }
3235}
3236```
3237
3238### createAssetRequest<sup>11+</sup>
3239
3240static createAssetRequest(context: Context, photoType: PhotoType, extension: string, options?: CreateOptions): MediaAssetChangeRequest
3241
3242Create an asset change request based on the file type and filename extension.
3243
3244**Atomic service API**: This API can be used in atomic services since API version 11.
3245
3246**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3247
3248**Parameters**
3249
3250| Name | Type   | Mandatory| Description                      |
3251| ------- | ------- | ---- | -------------------------- |
3252| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
3253| photoType  | [PhotoType](#phototype)        | Yes  | Type of the file to create, which can be **IMAGE** or **VIDEO**.             |
3254| extension  | string        | Yes  | File name extension, for example, **'jpg'**.             |
3255| options  | [CreateOptions](#createoptions)        | No  | Options for creating the image or video asset, for example, **{title: 'testPhoto'}**.             |
3256
3257**Return value**
3258
3259| Type                                   | Description             |
3260| --------------------------------------- | ----------------- |
3261| [MediaAssetChangeRequest](#mediaassetchangerequest11) | **MediaAssetChangeRequest** created.|
3262
3263**Error codes**
3264
3265For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3266
3267| ID| Error Message|
3268| -------- | ---------------------------------------- |
3269| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3270| 14000011       | System inner fail.         |
3271
3272**Example**
3273
3274```ts
3275async function example() {
3276  console.info('createAssetRequestDemo');
3277  try {
3278    let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
3279    let extension: string = 'jpg';
3280    let options: photoAccessHelper.CreateOptions = {
3281      title: 'testPhoto'
3282    }
3283    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createAssetRequest(context, photoType, extension, options);
3284    // Ensure that the asset specified by fileUri exists.
3285    let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
3286    assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, fileUri);
3287    await phAccessHelper.applyChanges(assetChangeRequest);
3288    console.info('apply createAssetRequest successfully');
3289  } catch (err) {
3290    console.error(`createAssetRequestDemo failed with error: ${err.code}, ${err.message}`);
3291  }
3292}
3293```
3294
3295### deleteAssets<sup>11+</sup>
3296
3297static deleteAssets(context: Context, assets: Array&lt;PhotoAsset&gt;): Promise&lt;void&gt;
3298
3299Deletes media assets. This API uses a promise to return the result. The deleted assets are moved to the trash.
3300
3301**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3302
3303**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3304
3305**Parameters**
3306
3307| Name | Type   | Mandatory| Description                      |
3308| ------- | ------- | ---- | -------------------------- |
3309| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
3310| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Media assets to delete.|
3311
3312**Return value**
3313
3314| Type                                   | Description             |
3315| --------------------------------------- | ----------------- |
3316| Promise&lt;void&gt;| Promise that returns no value.|
3317
3318**Error codes**
3319
3320For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3321
3322| ID| Error Message|
3323| -------- | ---------------------------------------- |
3324| 201      |  Permission denied.         |
3325| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3326| 14000011 |  System inner fail.         |
3327
3328**Example**
3329
3330```ts
3331import { dataSharePredicates } from '@kit.ArkData';
3332
3333async function example() {
3334  console.info('deleteAssetsDemo');
3335  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3336  let fetchOptions: photoAccessHelper.FetchOptions = {
3337    fetchColumns: [],
3338    predicates: predicates
3339  };
3340  try {
3341    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3342    let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects();
3343    await photoAccessHelper.MediaAssetChangeRequest.deleteAssets(context, photoAssetList);
3344    console.info('deleteAssets successfully');
3345  } catch (err) {
3346    console.error(`deleteAssetsDemo failed with error: ${err.code}, ${err.message}`);
3347  }
3348}
3349```
3350
3351### deleteAssets<sup>11+</sup>
3352
3353static deleteAssets(context: Context, uriList: Array&lt;string&gt;): Promise&lt;void&gt;
3354
3355Deletes media assets. This API uses a promise to return the result. The deleted assets are moved to the trash.
3356
3357**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3358
3359**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3360
3361**Parameters**
3362
3363| Name | Type   | Mandatory| Description                      |
3364| ------- | ------- | ---- | -------------------------- |
3365| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | Yes  | Context of the ability instance.|
3366| uriList | Array&lt;string&gt; | Yes  | URIs of the media files to delete.|
3367
3368**Return value**
3369
3370| Type                                   | Description             |
3371| --------------------------------------- | ----------------- |
3372| Promise&lt;void&gt;| Promise that returns no value.|
3373
3374**Error codes**
3375
3376For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3377
3378| ID| Error Message|
3379| -------- | ---------------------------------------- |
3380| 201      |  Permission denied.         |
3381| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3382| 14000002 |  Invalid asset uri.         |
3383| 14000011 |  System inner fail.         |
3384
3385**Example**
3386
3387```ts
3388import { dataSharePredicates } from '@kit.ArkData';
3389
3390async function example() {
3391  console.info('deleteAssetsDemo');
3392  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3393  let fetchOptions: photoAccessHelper.FetchOptions = {
3394    fetchColumns: [],
3395    predicates: predicates
3396  };
3397  try {
3398    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3399    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3400    await photoAccessHelper.MediaAssetChangeRequest.deleteAssets(context, [asset.uri]);
3401    console.info('deleteAssets successfully');
3402  } catch (err) {
3403    console.error(`deleteAssetsDemo failed with error: ${err.code}, ${err.message}`);
3404  }
3405}
3406```
3407
3408### getAsset<sup>11+</sup>
3409
3410getAsset(): PhotoAsset
3411
3412Obtains the asset in this asset change request.
3413
3414> **NOTE**<br>For the change request used to create an asset, this API returns **null** before [applyChanges](#applychanges11) is called to apply the changes.
3415
3416**Atomic service API**: This API can be used in atomic services since API version 12.
3417
3418**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3419
3420**Return value**
3421
3422| Type                                   | Description             |
3423| --------------------------------------- | ----------------- |
3424| [PhotoAsset](#photoasset) | Asset obtained.|
3425
3426**Error codes**
3427
3428For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3429
3430| ID| Error Message|
3431| -------- | ---------------------------------------- |
3432| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3433| 14000011 |  System inner fail.         |
3434
3435**Example**
3436
3437```ts
3438async function example() {
3439  console.info('getAssetDemo');
3440  try {
3441    // Ensure that the asset specified by fileUri exists.
3442    let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
3443    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createImageAssetRequest(context, fileUri);
3444    await phAccessHelper.applyChanges(assetChangeRequest);
3445    let asset: photoAccessHelper.PhotoAsset = assetChangeRequest.getAsset();
3446    console.info('create asset successfully with uri = ' + asset.uri);
3447  } catch (err) {
3448    console.error(`getAssetDemo failed with error: ${err.code}, ${err.message}`);
3449  }
3450}
3451```
3452
3453### setTitle<sup>11+</sup>
3454
3455setTitle(title: string): void
3456
3457Sets the media asset title.
3458
3459**Atomic service API**: This API can be used in atomic services since API version 12.
3460
3461**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3462
3463**Parameters**
3464
3465| Name       | Type     | Mandatory  | Description                                |
3466| ---------- | ------- | ---- | ---------------------------------- |
3467| title | string | Yes  | Title to set.|
3468
3469The title must meet the following requirements:
3470- It does not contain a file name extension.
3471- The file name cannot exceed 255 characters.
3472- It does not contain any of the following characters:<br> . \ / : * ? " ' ` < > | { } [ ]
3473
3474**Error codes**
3475
3476For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3477
3478| ID| Error Message|
3479| -------- | ---------------------------------------- |
3480| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3481| 14000011       | System inner fail.         |
3482
3483**Example**
3484
3485```ts
3486import { dataSharePredicates } from '@kit.ArkData';
3487import { BusinessError } from '@kit.BasicServicesKit';
3488
3489async function example() {
3490  console.info('setTitleDemo');
3491  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3492  let fetchOption: photoAccessHelper.FetchOptions = {
3493    fetchColumns: [],
3494    predicates: predicates
3495  };
3496  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
3497  let asset = await fetchResult.getFirstObject();
3498  let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
3499  let newTitle: string = 'newTitle';
3500  assetChangeRequest.setTitle(newTitle);
3501  phAccessHelper.applyChanges(assetChangeRequest).then(() => {
3502    console.info('apply setTitle successfully');
3503  }).catch((err: BusinessError) => {
3504    console.error(`apply setTitle failed with error: ${err.code}, ${err.message}`);
3505  });
3506}
3507```
3508
3509### getWriteCacheHandler<sup>11+</sup>
3510
3511getWriteCacheHandler(): Promise&lt;number&gt;
3512
3513Obtains the handler used for writing a file to cache.
3514
3515> **NOTE**<br>For the same asset change request, this API cannot be repeatedly called after a temporary file write handle is successfully obtained.
3516
3517**Required permissions**: ohos.permission.WRITE_IMAGEVIDEO
3518
3519**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3520
3521**Return value**
3522
3523| Type                                   | Description             |
3524| --------------------------------------- | ----------------- |
3525| Promise&lt;number&gt; | Promise used to return the write handle obtained.|
3526
3527**Error codes**
3528
3529For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3530
3531| ID| Error Message|
3532| -------- | ---------------------------------------- |
3533| 201   | Permission denied.        |
3534| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3535| 14000011 |  System inner fail.         |
3536| 14000016 |  Operation Not Support.     |
3537
3538**Example**
3539
3540```ts
3541import { fileIo } from '@kit.CoreFileKit';
3542
3543async function example() {
3544  console.info('getWriteCacheHandlerDemo');
3545  try {
3546    let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.VIDEO;
3547    let extension: string = 'mp4';
3548    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createAssetRequest(context, photoType, extension);
3549    let fd: number = await assetChangeRequest.getWriteCacheHandler();
3550    console.info('getWriteCacheHandler successfully');
3551    // write date into fd
3552    await fileIo.close(fd);
3553    await phAccessHelper.applyChanges(assetChangeRequest);
3554  } catch (err) {
3555    console.error(`getWriteCacheHandlerDemo failed with error: ${err.code}, ${err.message}`);
3556  }
3557}
3558```
3559
3560### addResource<sup>11+</sup>
3561
3562addResource(type: ResourceType, fileUri: string): void
3563
3564Adds a resource using **fileUri**.
3565
3566> **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.
3567
3568**Atomic service API**: This API can be used in atomic services since API version 11.
3569
3570**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3571
3572**Parameters**
3573
3574| Name | Type   | Mandatory| Description                      |
3575| ------- | ------- | ---- | -------------------------- |
3576| type | [ResourceType](#resourcetype11) | Yes  | Type of the resource to add.|
3577| fileUri | string | Yes  | Data source of the resource to be added, which is specified by a URI in the application sandbox directory.|
3578
3579**Error codes**
3580
3581For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3582
3583| ID| Error Message|
3584| -------- | ---------------------------------------- |
3585| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3586| 13900002      |  No such file.   |
3587| 14000011 |  System inner fail.         |
3588| 14000016 |  Operation Not Support.     |
3589
3590**Example**
3591
3592```ts
3593async function example() {
3594  console.info('addResourceByFileUriDemo');
3595  try {
3596    let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
3597    let extension: string = 'jpg';
3598    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createAssetRequest(context, photoType, extension);
3599    // Ensure that the asset specified by fileUri exists.
3600    let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
3601    assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, fileUri);
3602    await phAccessHelper.applyChanges(assetChangeRequest);
3603    console.info('addResourceByFileUri successfully');
3604  } catch (err) {
3605    console.error(`addResourceByFileUriDemo failed with error: ${err.code}, ${err.message}`);
3606  }
3607}
3608```
3609
3610### addResource<sup>11+</sup>
3611
3612addResource(type: ResourceType, data: ArrayBuffer): void
3613
3614Adds a resource using **ArrayBuffer** data.
3615
3616> **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.
3617
3618**Atomic service API**: This API can be used in atomic services since API version 11.
3619
3620**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3621
3622**Parameters**
3623
3624| Name | Type   | Mandatory| Description                      |
3625| ------- | ------- | ---- | -------------------------- |
3626| type | [ResourceType](#resourcetype11) | Yes  | Type of the resource to add.|
3627| data | ArrayBuffer | Yes  | Data of the resource to add.|
3628
3629**Error codes**
3630
3631For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3632
3633| ID| Error Message|
3634| -------- | ---------------------------------------- |
3635| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3636| 14000011 |  System inner fail.         |
3637| 14000016 |  Operation Not Support.     |
3638
3639**Example**
3640
3641```ts
3642async function example() {
3643  console.info('addResourceByArrayBufferDemo');
3644  try {
3645    let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
3646    let extension: string = 'jpg';
3647    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createAssetRequest(context, photoType, extension);
3648    let buffer: ArrayBuffer = new ArrayBuffer(2048);
3649    assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, buffer);
3650    await phAccessHelper.applyChanges(assetChangeRequest);
3651    console.info('addResourceByArrayBuffer successfully');
3652  } catch (err) {
3653    console.error(`addResourceByArrayBufferDemo failed with error: ${err.code}, ${err.message}`);
3654  }
3655}
3656```
3657
3658### saveCameraPhoto<sup>12+</sup>
3659
3660saveCameraPhoto(): void
3661
3662Saves the photo taken by the camera.
3663
3664**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3665
3666**Error codes**
3667
3668For details about the error codes, see [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3669
3670| ID| Error Message|
3671| -------- | ---------------------------------------- |
3672| 14000011 |  System inner fail.         |
3673| 14000016 |  Operation Not Support.         |
3674
3675**Example**
3676
3677```ts
3678async function example(asset: photoAccessHelper.PhotoAsset) {
3679  console.info('saveCameraPhotoDemo');
3680  try {
3681    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
3682    assetChangeRequest.saveCameraPhoto();
3683    await phAccessHelper.applyChanges(assetChangeRequest);
3684    console.info('apply saveCameraPhoto successfully');
3685  } catch (err) {
3686    console.error(`apply saveCameraPhoto failed with error: ${err.code}, ${err.message}`);
3687  }
3688}
3689```
3690
3691### saveCameraPhoto<sup>13+</sup>
3692
3693saveCameraPhoto(imageFileType: ImageFileType): void
3694
3695Saves the photo taken by the camera.
3696
3697**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3698
3699**Parameters**
3700
3701| Name  | Type                     | Mandatory| Description      |
3702| -------- | ------------------------- | ---- | ---------- |
3703| imageFileType | [ImageFileType](#imagefiletype13)  | Yes  | File type of the photo to save.|
3704
3705**Error codes**
3706
3707For details about the error codes, see [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3708
3709| ID| Error Message|
3710| -------- | ---------------------------------------- |
3711| 14000011 |  System inner fail.         |
3712| 14000016 |  Operation Not Support.         |
3713
3714**Example**
3715
3716```ts
3717import { photoAccessHelper } from '@kit.MediaLibraryKit';
3718import { dataSharePredicates } from '@kit.ArkData';
3719import { image } from '@kit.ImageKit';
3720
3721async function example(asset: photoAccessHelper.PhotoAsset) {
3722  console.info('saveCameraPhotoDemo');
3723  try {
3724    let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
3725    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
3726    assetChangeRequest.saveCameraPhoto(photoAccessHelper.ImageFileType.JPEG);
3727    await phAccessHelper.applyChanges(assetChangeRequest);
3728    console.info('apply saveCameraPhoto successfully');
3729  } catch (err) {
3730    console.error(`apply saveCameraPhoto failed with error: ${err.code}, ${err.message}`);
3731  }
3732}
3733```
3734
3735### discardCameraPhoto<sup>12+</sup>
3736
3737discardCameraPhoto(): void
3738
3739Discards the photo taken by the camera.
3740
3741**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3742
3743**Error codes**
3744
3745For details about the error codes, see [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3746
3747| ID| Error Message|
3748| -------- | ---------------------------------------- |
3749| 14000011 |  Internal system error.         |
3750| 14000016 |  Operation Not Support.         |
3751
3752**Example**
3753
3754```ts
3755async function example(asset: photoAccessHelper.PhotoAsset) {
3756  console.info('discardCameraPhotoDemo');
3757  try {
3758    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
3759    assetChangeRequest.discardCameraPhoto();
3760    await phAccessHelper.applyChanges(assetChangeRequest);
3761    console.info('apply discardCameraPhoto successfully');
3762  } catch (err) {
3763    console.error(`apply discardCameraPhoto failed with error: ${err.code}, ${err.message}`);
3764  }
3765}
3766```
3767
3768## MediaAlbumChangeRequest<sup>11+</sup>
3769
3770Provides APIs for managing the media album change request.
3771
3772**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3773
3774### constructor<sup>11+</sup>
3775
3776constructor(album: Album)
3777
3778Constructor.
3779
3780**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3781
3782**Parameters**
3783
3784| Name  | Type                     | Mandatory| Description      |
3785| -------- | ------------------------- | ---- | ---------- |
3786| album | [Album](#album) | Yes  | Album to change.|
3787
3788**Error codes**
3789
3790For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3791
3792| ID| Error Message|
3793| -------- | ---------------------------------------- |
3794| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3795| 14000011       | System inner fail.          |
3796
3797**Example**
3798
3799```ts
3800import { dataSharePredicates } from '@kit.ArkData';
3801
3802async function example() {
3803  console.info('MediaAlbumChangeRequest constructorDemo');
3804  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3805  let fetchOptions: photoAccessHelper.FetchOptions = {
3806    fetchColumns: [],
3807    predicates: predicates
3808  };
3809  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions);
3810  let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
3811  let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
3812}
3813```
3814
3815### getAlbum<sup>11+</sup>
3816
3817getAlbum(): Album
3818
3819Obtains the album in the current album change request.
3820
3821> **NOTE**<br>For the change request for creating an album, this API returns **null** before [applyChanges](#applychanges11) is called to apply the changes.
3822
3823**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3824
3825**Return value**
3826
3827| Type                                   | Description             |
3828| --------------------------------------- | ----------------- |
3829| [Album](#album) | Album obtained.|
3830
3831**Error codes**
3832
3833For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3834
3835| ID| Error Message|
3836| -------- | ---------------------------------------- |
3837| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3838| 14000011 |  System inner fail.         |
3839
3840**Example**
3841
3842```ts
3843async function example() {
3844  console.info('getAlbumDemo');
3845  try {
3846    // Ensure that the user album exists in the gallery.
3847    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
3848    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
3849    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
3850    let changeRequestAlbum: photoAccessHelper.Album = albumChangeRequest.getAlbum();
3851    console.info('change request album uri: ' + changeRequestAlbum.albumUri);
3852  } catch (err) {
3853    console.error(`getAlbumDemo failed with error: ${err.code}, ${err.message}`);
3854  }
3855}
3856```
3857
3858### setAlbumName<sup>11+</sup>
3859
3860setAlbumName(name: string): void
3861
3862Sets the album name.
3863
3864The album name must comply with the following specifications:
3865- It does not exceed 255 characters.
3866- It does not contain any of the following characters:<br> . \ / : * ? " ' ` < > | { } [ ]
3867- It is case-insensitive.
3868- Duplicate album names are not allowed.
3869
3870**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3871
3872**Parameters**
3873
3874| Name       | Type     | Mandatory  | Description                                |
3875| ---------- | ------- | ---- | ---------------------------------- |
3876| name | string | Yes  | Album name to set.|
3877
3878**Error codes**
3879
3880For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3881
3882| ID| Error Message|
3883| -------- | ---------------------------------------- |
3884| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3885| 14000011       | System inner fail.         |
3886
3887**Example**
3888
3889```ts
3890async function example() {
3891  console.info('setAlbumNameDemo');
3892  try {
3893    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
3894    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
3895    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
3896    let newAlbumName: string = 'newAlbumName' + new Date().getTime();
3897    albumChangeRequest.setAlbumName(newAlbumName);
3898    await phAccessHelper.applyChanges(albumChangeRequest);
3899    console.info('setAlbumName successfully');
3900  } catch (err) {
3901    console.error(`setAlbumNameDemo failed with error: ${err.code}, ${err.message}`);
3902  }
3903}
3904```
3905
3906### addAssets<sup>11+</sup>
3907
3908addAssets(assets: Array&lt;PhotoAsset&gt;): void
3909
3910Add assets to the album.
3911
3912**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3913
3914**Parameters**
3915
3916| Name       | Type     | Mandatory  | Description                                |
3917| ---------- | ------- | ---- | ---------------------------------- |
3918| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Assets to add.|
3919
3920**Error codes**
3921
3922For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3923
3924| ID| Error Message|
3925| -------- | ---------------------------------------- |
3926| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3927| 14000011       | System inner fail.         |
3928| 14000016 |  Operation Not Support.     |
3929
3930**Example**
3931
3932```ts
3933import { dataSharePredicates } from '@kit.ArkData';
3934
3935async function example() {
3936  console.info('addAssetsDemo');
3937  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3938  let fetchOptions: photoAccessHelper.FetchOptions = {
3939    fetchColumns: [],
3940    predicates: predicates
3941  };
3942  try {
3943    // Ensure that user albums and photos exist in Gallery.
3944    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3945    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3946    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
3947    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
3948    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
3949    albumChangeRequest.addAssets([asset]);
3950    await phAccessHelper.applyChanges(albumChangeRequest);
3951    console.info('addAssets successfully');
3952  } catch (err) {
3953    console.error(`addAssetsDemo failed with error: ${err.code}, ${err.message}`);
3954  }
3955}
3956```
3957
3958### removeAssets<sup>11+</sup>
3959
3960removeAssets(assets: Array&lt;PhotoAsset&gt;): void
3961
3962Removes assets from the album.
3963
3964**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
3965
3966**Parameters**
3967
3968| Name       | Type     | Mandatory  | Description                                |
3969| ---------- | ------- | ---- | ---------------------------------- |
3970| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | Yes  | Assets to remove.|
3971
3972**Error codes**
3973
3974For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
3975
3976| ID| Error Message|
3977| -------- | ---------------------------------------- |
3978| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3979| 14000011       | System inner fail.         |
3980| 14000016 |  Operation Not Support.     |
3981
3982**Example**
3983
3984```ts
3985import { dataSharePredicates } from '@kit.ArkData';
3986
3987async function example() {
3988  console.info('removeAssetsDemo');
3989  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3990  let fetchOptions: photoAccessHelper.FetchOptions = {
3991    fetchColumns: [],
3992    predicates: predicates
3993  };
3994  try {
3995    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
3996    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
3997    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions);
3998    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3999
4000    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
4001    albumChangeRequest.removeAssets([asset]);
4002    await phAccessHelper.applyChanges(albumChangeRequest);
4003    console.info('removeAssets successfully');
4004  } catch (err) {
4005    console.error(`removeAssetsDemo failed with error: ${err.code}, ${err.message}`);
4006  }
4007}
4008```
4009
4010## MediaAssetManager<sup>11+</sup>
4011
4012A media asset manager class, used for manipulating the read and write operations of media assets.
4013
4014**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4015
4016### requestImage<sup>11+</sup>
4017
4018static requestImage(context: Context, asset: PhotoAsset, requestOptions: RequestOptions, dataHandler: MediaAssetDataHandler&lt;image.ImageSource&gt;): Promise&lt;string&gt;
4019
4020Requests an image.
4021
4022**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4023
4024**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4025
4026- If the caller does not have the ohos.permission.READ_IMAGEVIDEO permission, use Picker to access the file and then call this API based on the URI obtained by Picker. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
4027- For the media assets saved to the media library by this application, the application can access them without the ohos.permission.READ_IMAGEVIDEO permission.
4028
4029**Parameters**
4030
4031| Name           | Type                                                                                                       | Mandatory| Description                     |
4032|----------------|-----------------------------------------------------------------------------------------------------------| ---- | ------------------------- |
4033| context        | [Context](../apis-ability-kit/js-apis-inner-application-context.md)                                                           | Yes  | Context of the ability instance.|
4034| asset         | [PhotoAsset](#photoasset)                                                                                | Yes  | Image to request.|
4035| requestOptions | [RequestOptions](#requestoptions11)                                                                        | Yes  | Options for requesting the image.|
4036| 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.|
4037
4038**Return value**
4039
4040| Type                                   | Description             |
4041| --------------------------------------- | ----------------- |
4042| Promise\<string> | Promise used to return the request ID, which can be used in [cancelRequest](#cancelrequest12) to cancel a request.|
4043
4044**Error codes**
4045
4046For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4047
4048| ID| Error Message|
4049| -------- | ---------------------------------------- |
4050| 201      |  Permission denied         |
4051| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4052| 14000011       | System inner fail.         |
4053
4054**Example**
4055
4056```ts
4057import { dataSharePredicates } from '@kit.ArkData';
4058import { image } from '@kit.ImageKit';
4059
4060class MediaHandler implements photoAccessHelper.MediaAssetDataHandler<image.ImageSource> {
4061  onDataPrepared(data: image.ImageSource) {
4062    if (data === undefined) {
4063      console.error('Error occurred when preparing data');
4064      return;
4065    }
4066    console.info('on image data prepared');
4067  }
4068}
4069
4070async function example() {
4071  console.info('requestImage');
4072  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4073  let fetchOptions: photoAccessHelper.FetchOptions = {
4074    fetchColumns: [],
4075    predicates: predicates
4076  };
4077  let requestOptions: photoAccessHelper.RequestOptions = {
4078    deliveryMode: photoAccessHelper.DeliveryMode.HIGH_QUALITY_MODE,
4079  }
4080  const handler = new MediaHandler();
4081
4082  phAccessHelper.getAssets(fetchOptions, async (err, fetchResult) => {
4083      console.info('fetchResult success');
4084      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
4085      await photoAccessHelper.MediaAssetManager.requestImage(context, photoAsset, requestOptions, handler);
4086      console.info('requestImage successfully');
4087  });
4088}
4089```
4090
4091### requestImageData<sup>11+</sup>
4092
4093static requestImageData(context: Context, asset: PhotoAsset, requestOptions: RequestOptions, dataHandler: MediaAssetDataHandler&lt;ArrayBuffer&gt;): Promise&lt;string&gt;
4094
4095Requests an image.
4096
4097**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4098
4099**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4100
4101- If the caller does not have the ohos.permission.READ_IMAGEVIDEO permission, use Picker to access the file and then call this API based on the URI obtained by Picker. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
4102- For the media assets saved to the media library by this application, the application can access them without the ohos.permission.READ_IMAGEVIDEO permission.
4103
4104**Parameters**
4105
4106| Name  | Type                                                                  | Mandatory| Description                     |
4107| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
4108| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md)                      | Yes  | Context of the ability instance.|
4109| asset | [PhotoAsset](#photoasset)                                            | Yes  | Image to request.|
4110| requestOptions  | [RequestOptions](#requestoptions11)                                  | Yes  | Options for requesting the image.|
4111| dataHandler  | [MediaAssetDataHandler](#mediaassetdatahandler11)&lt;ArrayBuffer&gt; | Yes  | Media asset handler, which invokes a callback to return the image when the requested image is ready.|
4112
4113**Return value**
4114
4115| Type                                   | Description             |
4116| --------------------------------------- | ----------------- |
4117| Promise\<string> | Promise used to return the request ID, which can be used in [cancelRequest](#cancelrequest12) to cancel a request.|
4118
4119**Error codes**
4120
4121For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4122
4123| ID| Error Message|
4124| -------- | ---------------------------------------- |
4125| 201      |  Permission denied         |
4126| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4127| 14000011       | System inner fail.         |
4128
4129**Example**
4130
4131```ts
4132import { dataSharePredicates } from '@kit.ArkData';
4133class MediaDataHandler implements photoAccessHelper.MediaAssetDataHandler<ArrayBuffer> {
4134  onDataPrepared(data: ArrayBuffer) {
4135    if (data === undefined) {
4136      console.error('Error occurred when preparing data');
4137      return;
4138    }
4139    console.info('on image data prepared');
4140  }
4141}
4142
4143async function example() {
4144  console.info('requestImageData');
4145  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4146  let fetchOptions: photoAccessHelper.FetchOptions = {
4147    fetchColumns: [],
4148    predicates: predicates
4149  };
4150  let requestOptions: photoAccessHelper.RequestOptions = {
4151    deliveryMode: photoAccessHelper.DeliveryMode.HIGH_QUALITY_MODE,
4152  }
4153  const handler = new MediaDataHandler();
4154
4155  phAccessHelper.getAssets(fetchOptions, async (err, fetchResult) => {
4156      console.info('fetchResult success');
4157      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
4158      await photoAccessHelper.MediaAssetManager.requestImageData(context, photoAsset, requestOptions, handler);
4159      console.info('requestImageData successfully');
4160  });
4161}
4162```
4163
4164### requestMovingPhoto<sup>12+</sup>
4165
4166static requestMovingPhoto(context: Context, asset: PhotoAsset, requestOptions: RequestOptions, dataHandler: MediaAssetDataHandler&lt;MovingPhoto&gt;): Promise&lt;string&gt;
4167
4168Requests a moving photo object, which can be used to request the asset data of the moving photo.
4169
4170**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4171
4172**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4173
4174- If the caller does not have the ohos.permission.READ_IMAGEVIDEO permission, use Picker to access the file and then call this API based on the URI obtained by Picker. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
4175- For the moving photos saved to the media library by this application, the application can access them without the ohos.permission.READ_IMAGEVIDEO permission.
4176
4177**Parameters**
4178
4179| Name  | Type                                                                  | Mandatory| Description                     |
4180| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
4181| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md)                      | Yes  | Context of the ability instance.|
4182| asset | [PhotoAsset](#photoasset)                                            | Yes  | Image to request.|
4183| requestOptions  | [RequestOptions](#requestoptions11)                                  | Yes  | Options for requesting the image.|
4184| 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.|
4185
4186**Return value**
4187
4188| Type                                   | Description             |
4189| --------------------------------------- | ----------------- |
4190| Promise\<string> | Promise used to return the request ID, which can be used in [cancelRequest](#cancelrequest12) to cancel a request.|
4191
4192**Error codes**
4193
4194For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4195
4196| ID| Error Message|
4197| -------- | ---------------------------------------- |
4198| 201      |  Permission denied         |
4199| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4200| 14000011       | System inner fail         |
4201
4202**Example**
4203
4204```ts
4205import { dataSharePredicates } from '@kit.ArkData';
4206
4207class MovingPhotoHandler implements photoAccessHelper.MediaAssetDataHandler<photoAccessHelper.MovingPhoto> {
4208  async onDataPrepared(movingPhoto: photoAccessHelper.MovingPhoto) {
4209    if (movingPhoto === undefined) {
4210      console.error('Error occurred when preparing data');
4211      return;
4212    }
4213    console.info("moving photo acquired successfully, uri: " + movingPhoto.getUri());
4214  }
4215}
4216
4217async function example() {
4218  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4219  predicates.equalTo(photoAccessHelper.PhotoKeys.PHOTO_SUBTYPE, photoAccessHelper.PhotoSubtype.MOVING_PHOTO);
4220  let fetchOptions: photoAccessHelper.FetchOptions = {
4221    fetchColumns: [],
4222    predicates: predicates
4223  };
4224  // Ensure that there are moving photos in Gallery.
4225  let assetResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
4226  let asset: photoAccessHelper.PhotoAsset = await assetResult.getFirstObject();
4227  let requestOptions: photoAccessHelper.RequestOptions = {
4228    deliveryMode: photoAccessHelper.DeliveryMode.FAST_MODE,
4229  }
4230  const handler = new MovingPhotoHandler();
4231  try {
4232    let requestId: string = await photoAccessHelper.MediaAssetManager.requestMovingPhoto(context, asset, requestOptions, handler);
4233    console.info("moving photo requested successfully, requestId: " + requestId);
4234  } catch (err) {
4235    console.error(`failed to request moving photo, error code is ${err.code}, message is ${err.message}`);
4236  }
4237}
4238
4239```
4240
4241### requestVideoFile<sup>12+</sup>
4242
4243static requestVideoFile(context: Context, asset: PhotoAsset, requestOptions: RequestOptions, fileUri: string, dataHandler: MediaAssetDataHandler&lt;boolean&gt;): Promise&lt;string&gt;
4244
4245Requests a video and saves it to the specified sandbox directory.
4246
4247**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4248
4249**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4250
4251- If the caller does not have the ohos.permission.READ_IMAGEVIDEO permission, use Picker to access the file and then call this API based on the URI obtained by Picker. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
4252- For the videos saved to the media library by this application, the application can access them without the ohos.permission.READ_IMAGEVIDEO permission.
4253
4254**Parameters**
4255
4256| Name  | Type                                                                  | Mandatory| Description                     |
4257| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
4258| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md)                      | Yes  | Context of the ability instance.|
4259| asset | [PhotoAsset](#photoasset)                                            | Yes  | Image to request.|
4260| requestOptions  | [RequestOptions](#requestoptions11)                                  | Yes  | Options for requesting the video asset.|
4261| fileUri| string                                                              | Yes| URI of the sandbox directory, to which the requested video asset is to be saved.|
4262| dataHandler  | [MediaAssetDataHandler](#mediaassetdatahandler11)&lt;boolean&gt; | Yes  | Media asset handler. When the requested video is written to the specified directory, a callback is triggered.|
4263
4264**Return value**
4265
4266| Type                                   | Description             |
4267| --------------------------------------- | ----------------- |
4268| Promise\<string> | Promise used to return the request ID, which can be used in [cancelRequest](#cancelrequest12) to cancel a request.|
4269
4270**Error codes**
4271
4272For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4273
4274| ID| Error Message|
4275| -------- | ---------------------------------------- |
4276| 201      |  Permission denied         |
4277| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4278| 14000011       | System inner fail.         |
4279
4280**Example**
4281
4282```ts
4283import { dataSharePredicates } from '@kit.ArkData';
4284class MediaDataHandler implements photoAccessHelper.MediaAssetDataHandler<boolean> {
4285    onDataPrepared(data: boolean) {
4286        console.info('on video request status prepared');
4287    }
4288}
4289
4290async function example() {
4291  console.info('requestVideoFile');
4292  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4293  let fetchOptions: photoAccessHelper.FetchOptions = {
4294    fetchColumns: [],
4295    predicates: predicates
4296  };
4297  let requestOptions: photoAccessHelper.RequestOptions = {
4298    deliveryMode: photoAccessHelper.DeliveryMode.HIGH_QUALITY_MODE,
4299  }
4300  const handler = new MediaDataHandler();
4301  let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.mp4';
4302  phAccessHelper.getAssets(fetchOptions, async (err, fetchResult) => {
4303      console.info('fetchResult success');
4304      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
4305      await photoAccessHelper.MediaAssetManager.requestVideoFile(context, photoAsset, requestOptions, fileUri, handler);
4306      console.info('requestVideoFile successfully');
4307  });
4308}
4309```
4310
4311### cancelRequest<sup>12+</sup>
4312
4313static cancelRequest(context: Context, requestId: string): Promise\<void>
4314
4315Cancels a request for the asset, the callback of which has not been triggered yet.
4316
4317**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4318
4319**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4320
4321**Parameters**
4322
4323| Name  | Type                                                                  | Mandatory| Description                     |
4324| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
4325| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md)                      | Yes  | Context of the ability instance.|
4326| requestId | string     | Yes  | ID of the request to cancel.|
4327
4328**Return value**
4329
4330| Type                                   | Description             |
4331| --------------------------------------- | ----------------- |
4332| Promise\<void> | Promise that returns no value.|
4333
4334**Error codes**
4335
4336For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4337
4338| ID| Error Message|
4339| -------- | ---------------------------------------- |
4340| 201      |  Permission denied         |
4341| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4342| 14000011       | System inner fail         |
4343
4344**Example**
4345
4346```ts
4347import { dataSharePredicates } from '@kit.ArkData';
4348
4349async function example() {
4350  try {
4351    let requestId: string = 'xxx-xxx'; // A valid requestId returned by APIs such as requestImage() must be used.
4352    await photoAccessHelper.MediaAssetManager.cancelRequest(context, requestId);
4353    console.info("request cancelled successfully");
4354  } catch (err) {
4355    console.error(`cancelRequest failed with error: ${err.code}, ${err.message}`);
4356  }
4357}
4358
4359```
4360
4361### loadMovingPhoto<sup>12+</sup>
4362
4363static loadMovingPhoto(context: Context, imageFileUri: string, videoFileUri: string): Promise\<MovingPhoto>
4364
4365Loads a moving photo in the application sandbox.
4366
4367**Atomic service API**: This API can be used in atomic services since API version 14.
4368
4369**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4370
4371**Parameters**
4372
4373| Name  | Type                                                                  | Mandatory| Description                     |
4374| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
4375| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md)   | Yes  | **AbilityContext** or **UIExtensionContext** instance.|
4376| imageFileUri | string     | Yes  | URI of the image file of the moving photo in the application sandbox.|
4377| videoFileUri | string     | Yes  | URI of the video file of the moving photo in the application sandbox.|
4378
4379**Return value**
4380
4381| Type                                   | Description             |
4382| --------------------------------------- | ----------------- |
4383| Promise\<MovingPhoto> | Promise used to return a [MovingPhoto](#movingphoto12) instance.|
4384
4385**Error codes**
4386
4387For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4388
4389| ID| Error Message|
4390| -------- | ---------------------------------------- |
4391| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4392| 14000011 | Internal system error. |
4393
4394**Example**
4395
4396```ts
4397async function example() {
4398  try {
4399    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.
4400    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.
4401    let movingPhoto: photoAccessHelper.MovingPhoto = await photoAccessHelper.MediaAssetManager.loadMovingPhoto(context, imageFileUri, videoFileUri);
4402  } catch (err) {
4403    console.error(`loadMovingPhoto failed with error: ${err.code}, ${err.message}`);
4404  }
4405}
4406
4407```
4408
4409### quickRequestImage<sup>13+</sup>
4410
4411static quickRequestImage(context: Context, asset: PhotoAsset, requestOptions: RequestOptions, dataHandler: QuickImageDataHandler&lt;image.Picture&gt;): Promise&lt;string&gt;
4412
4413Requests an image quickly.
4414
4415**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4416
4417**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4418
4419If the caller does not have the ohos.permission.READ_IMAGEVIDEO permission, use Picker to access the file and then call this API based on the URI obtained by Picker. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
4420
4421**Parameters**
4422
4423| Name           | Type                                                                                                       | Mandatory| Description                     |
4424|----------------|-----------------------------------------------------------------------------------------------------------| ---- | ------------------------- |
4425| context        | [Context](../apis-ability-kit/js-apis-inner-application-context.md)                                                           | Yes  | Context of the ability instance.|
4426| asset         | [PhotoAsset](#photoasset)                                                                                | Yes  | Image to request.|
4427| requestOptions | [RequestOptions](#requestoptions11)                                                                        | Yes  | Options for requesting the image.|
4428| 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.|
4429
4430**Return value**
4431
4432| Type                                   | Description             |
4433| --------------------------------------- | ----------------- |
4434| Promise\<string> | Promise used to return the request ID, which can be used in [cancelRequest](#cancelrequest12) to cancel a request.|
4435
4436**Error codes**
4437
4438For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4439
4440| ID| Error Message|
4441| -------- | ---------------------------------------- |
4442| 201      |  Permission denied         |
4443| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4444| 14000011       | Internal system error.         |
4445
4446**Example**
4447
4448```ts
4449import { photoAccessHelper } from '@kit.MediaLibraryKit';
4450import { dataSharePredicates } from '@kit.ArkData';
4451import { image } from '@kit.ImageKit';
4452
4453class MediaHandler implements photoAccessHelper.QuickImageDataHandler<image.Picture> {
4454  onDataPrepared(data: image.Picture, imageSource: image.ImageSource, map: Map<string, string>) {
4455    console.info('on image data prepared');
4456  }
4457}
4458
4459async function example() {
4460  console.info('quickRequestImage');
4461  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4462  let fetchOptions: photoAccessHelper.FetchOptions = {
4463    fetchColumns: [],
4464    predicates: predicates
4465  };
4466  let requestOptions: photoAccessHelper.RequestOptions = {
4467    deliveryMode: photoAccessHelper.DeliveryMode.HIGH_QUALITY_MODE,
4468  }
4469  const handler = new MediaHandler();
4470  let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
4471  phAccessHelper.getAssets(fetchOptions, async (err, fetchResult) => {
4472      console.info('fetchResult success');
4473      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
4474      await photoAccessHelper.MediaAssetManager.quickRequestImage(context, photoAsset, requestOptions, handler);
4475      console.info('quickRequestImage successfully');
4476  });
4477}
4478```
4479
4480## MediaAssetDataHandler<sup>11+</sup>
4481
4482Media asset handler, which can be used to customize the media asset processing logic in **onDataPrepared**.
4483
4484**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4485
4486### onDataPrepared<sup>11+</sup>
4487
4488onDataPrepared(data: T, map?: Map<string, string>): void
4489
4490Called 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.
4491T 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.
4492
4493Information returned by **map**:
4494| Map Key | **Description**|
4495|----------|-------|
4496| 'quality'  | Image quality. The value **high** means high quality, and **low** means poor quality.|
4497
4498**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4499
4500**Parameters**
4501
4502| Name | Type| Mandatory| Description                                                                           |
4503|------|---| ---- |-------------------------------------------------------------------------------|
4504| 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.|
4505| map<sup>12+</sup> | Map<string, string> | No  | Additional information about the image asset, such as the image quality.|
4506
4507**Example**
4508```ts
4509import { image } from '@kit.ImageKit';
4510
4511class MediaHandler implements photoAccessHelper.MediaAssetDataHandler<image.ImageSource> {
4512  onDataPrepared(data: image.ImageSource, map: Map<string, string>) {
4513    if (data === undefined) {
4514      console.error('Error occurred when preparing data');
4515      return;
4516    }
4517    // Customize the processing logic for ImageSource.
4518    console.info('on image data prepared, photo quality is ' + map['quality']);
4519  }
4520}
4521
4522class MediaDataHandler implements photoAccessHelper.MediaAssetDataHandler<ArrayBuffer> {
4523  onDataPrepared(data: ArrayBuffer, map: Map<string, string>) {
4524    if (data === undefined) {
4525      console.error('Error occurred when preparing data');
4526      return;
4527    }
4528    // Customize the processing logic for ArrayBuffer.
4529    console.info('on image data prepared, photo quality is ' + map['quality']);
4530  }
4531}
4532
4533class MovingPhotoHandler implements photoAccessHelper.MediaAssetDataHandler<photoAccessHelper.MovingPhoto> {
4534  onDataPrepared(data: photoAccessHelper.MovingPhoto, map: Map<string, string>) {
4535    if (data === undefined) {
4536      console.error('Error occurred when preparing data');
4537      return;
4538    }
4539    // Customize the processing logic for MovingPhoto.
4540    console.info('on image data prepared, photo quality is ' + map['quality']);
4541  }
4542}
4543```
4544
4545## QuickImageDataHandler<sup>13+</sup>
4546
4547Media asset handler, which can be used to customize the media asset processing logic in **onDataPrepared**.
4548
4549**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4550
4551### onDataPrepared<sup>13+</sup>
4552
4553onDataPrepared(data: T, imageSource: image.ImageSource, map: Map<string, string>): void
4554
4555Called when the requested image is ready. If an error occurs, **data** returned by the callback is **undefined**.
4556**T** supports the Picture data type.
4557
4558Information returned by **map**:
4559| Map Key | **Description**|
4560|----------|-------|
4561| 'quality'  | Image quality. The value **high** means high quality, and **low** means poor quality.|
4562
4563**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4564
4565**Parameters**
4566
4567| Name | Type| Mandatory| Description                                                                           |
4568|------|---| ---- |-------------------------------------------------------------------------------|
4569| 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.|
4570| imageSource | image.ImageSource | Yes  | Data of the image asset that is ready.|
4571| map<sup>13+</sup> | Map<string, string> | Yes  | Additional information about the image asset, such as the image quality.|
4572
4573**Example**
4574```ts
4575import { image } from '@kit.ImageKit';
4576
4577class MediaHandler implements photoAccessHelper.QuickImageDataHandler<image.Picture> {
4578  onDataPrepared(data: image.Picture, imageSource: image.ImageSource, map: Map<string, string>) {
4579    console.info('on image data prepared');
4580  }
4581}
4582```
4583
4584## MovingPhoto<sup>12+</sup>
4585
4586Provides APIs for managing a moving photo instance.
4587
4588**Atomic service API**: This API can be used in atomic services since API version 12.
4589
4590**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4591
4592### getUri<sup>12+</sup>
4593
4594getUri(): string
4595
4596Obtains the URI of this moving photo.
4597
4598**Atomic service API**: This API can be used in atomic services since API version 12.
4599
4600**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4601
4602**Return value**
4603
4604| Type                                   | Description             |
4605| --------------------------------------- | ----------------- |
4606| string | URI of the moving photo obtained.|
4607
4608**Error codes**
4609
4610For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4611
4612| ID| Error Message|
4613| -------- | ---------------------------------------- |
4614| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4615| 14000011 |  System inner fail.         |
4616
4617**Example**
4618
4619```ts
4620import { dataSharePredicates } from '@kit.ArkData';
4621
4622class MovingPhotoHandler implements photoAccessHelper.MediaAssetDataHandler<photoAccessHelper.MovingPhoto> {
4623  async onDataPrepared(movingPhoto: photoAccessHelper.MovingPhoto) {
4624    if (movingPhoto === undefined) {
4625      console.error('Error occurred when preparing data');
4626      return;
4627    }
4628    console.info("moving photo acquired successfully, uri: " + movingPhoto.getUri());
4629  }
4630}
4631
4632async function example() {
4633  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4634  predicates.equalTo(photoAccessHelper.PhotoKeys.PHOTO_SUBTYPE, photoAccessHelper.PhotoSubtype.MOVING_PHOTO);
4635  let fetchOptions: photoAccessHelper.FetchOptions = {
4636    fetchColumns: [],
4637    predicates: predicates
4638  };
4639  // Ensure that there are moving photos in Gallery.
4640  let assetResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
4641  let asset: photoAccessHelper.PhotoAsset = await assetResult.getFirstObject();
4642  let requestOptions: photoAccessHelper.RequestOptions = {
4643    deliveryMode: photoAccessHelper.DeliveryMode.FAST_MODE,
4644  }
4645  const handler = new MovingPhotoHandler();
4646  try {
4647    let requestId: string = await photoAccessHelper.MediaAssetManager.requestMovingPhoto(context, asset, requestOptions, handler);
4648    console.info("moving photo requested successfully, requestId: " + requestId);
4649  } catch (err) {
4650    console.error(`failed to request moving photo, error code is ${err.code}, message is ${err.message}`);
4651  }
4652}
4653```
4654
4655### requestContent<sup>12+</sup>
4656
4657requestContent(imageFileUri: string, videoFileUri: string): Promise\<void>
4658
4659Requests the image data and video data of this moving photo and writes them to the specified URIs, respectively.
4660
4661**Atomic service API**: This API can be used in atomic services since API version 12.
4662
4663**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4664
4665**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4666
4667- If the application does not have the ohos.permission.READ_IMAGEVIDEO permission, use Picker to call this API to request a moving photo object and read the content. For details, see [Accessing and Managing Moving Photos](../../media/medialibrary/photoAccessHelper-movingphoto.md).
4668- For the moving photos saved to the media library by this application, the application can access them without the ohos.permission.READ_IMAGEVIDEO permission.
4669
4670**Parameters**
4671
4672| Name  | Type                                                                  | Mandatory| Description                     |
4673| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
4674| imageFileUri | string                      | Yes  | URI to which the image data of the moving photo is to be written.|
4675| videoFileUri | string                                            | Yes  | URI to which the video data of the moving photo is to be written.|
4676
4677**Return value**
4678
4679| Type                                   | Description             |
4680| --------------------------------------- | ----------------- |
4681| Promise\<void> | Promise that returns no value.|
4682
4683**Error codes**
4684
4685For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4686
4687| ID| Error Message|
4688| -------- | ---------------------------------------- |
4689| 201      |  Permission denied   |
4690| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4691| 14000011 |  System inner fail         |
4692
4693**Example**
4694
4695```ts
4696import { dataSharePredicates } from '@kit.ArkData';
4697
4698class MovingPhotoHandler implements photoAccessHelper.MediaAssetDataHandler<photoAccessHelper.MovingPhoto> {
4699  async onDataPrepared(movingPhoto: photoAccessHelper.MovingPhoto) {
4700    if (movingPhoto === undefined) {
4701      console.error('Error occurred when preparing data');
4702      return;
4703    }
4704    // The URIs must be valid.
4705    let imageFileUri: string = "file://com.example.temptest/data/storage/el2/base/haps/ImageFile.jpg";
4706    let videoFileUri: string = "file://com.example.temptest/data/storage/el2/base/haps/VideoFile.mp4";
4707    try {
4708      await movingPhoto.requestContent(imageFileUri, videoFileUri);
4709      console.log("moving photo contents retrieved successfully");
4710    } catch (err) {
4711      console.error(`failed to retrieve contents of moving photo, error code is ${err.code}, message is ${err.message}`);
4712    }
4713  }
4714}
4715
4716async function example() {
4717  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4718  predicates.equalTo(photoAccessHelper.PhotoKeys.PHOTO_SUBTYPE, photoAccessHelper.PhotoSubtype.MOVING_PHOTO);
4719  let fetchOptions: photoAccessHelper.FetchOptions = {
4720    fetchColumns: [],
4721    predicates: predicates
4722  };
4723  // Ensure that there are moving photos in Gallery.
4724  let assetResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
4725  let asset: photoAccessHelper.PhotoAsset = await assetResult.getFirstObject();
4726  let requestOptions: photoAccessHelper.RequestOptions = {
4727    deliveryMode: photoAccessHelper.DeliveryMode.FAST_MODE,
4728  }
4729  const handler = new MovingPhotoHandler();
4730  try {
4731    let requestId: string = await photoAccessHelper.MediaAssetManager.requestMovingPhoto(context, asset, requestOptions, handler);
4732    console.info("moving photo requested successfully, requestId: " + requestId);
4733  } catch (err) {
4734    console.error(`failed to request moving photo, error code is ${err.code}, message is ${err.message}`);
4735  }
4736}
4737```
4738
4739### requestContent<sup>12+</sup>
4740
4741requestContent(resourceType: ResourceType, fileUri: string): Promise\<void>
4742
4743Requests the moving photo content of the specified resource type and writes it to the specified URI.
4744
4745**Atomic service API**: This API can be used in atomic services since API version 12.
4746
4747**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4748
4749**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4750
4751- If the application does not have the ohos.permission.READ_IMAGEVIDEO permission, use Picker to call this API to request a moving photo object and read the content. For details, see [Accessing and Managing Moving Photos](../../media/medialibrary/photoAccessHelper-movingphoto.md).
4752- For the moving photos saved to the media library by this application, the application can access them without the ohos.permission.READ_IMAGEVIDEO permission.
4753
4754**Parameters**
4755
4756| Name  | Type                                                                  | Mandatory| Description                     |
4757| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
4758| resourceType | [ResourceType](#resourcetype11)                      | Yes  | Resource type of the moving photo content to request.|
4759| fileUri | string                                                    | Yes  |URI to which the moving photo content is to be written.|
4760
4761**Return value**
4762
4763| Type                                   | Description             |
4764| --------------------------------------- | ----------------- |
4765| Promise\<void> | Promise that returns no value.|
4766
4767**Error codes**
4768
4769For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4770
4771| ID| Error Message|
4772| -------- | ---------------------------------------- |
4773| 201      |  Permission denied   |
4774| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4775| 14000011 |  System inner fail         |
4776
4777**Example**
4778
4779```ts
4780import { dataSharePredicates } from '@kit.ArkData';
4781
4782class MovingPhotoHandler implements photoAccessHelper.MediaAssetDataHandler<photoAccessHelper.MovingPhoto> {
4783  async onDataPrepared(movingPhoto: photoAccessHelper.MovingPhoto) {
4784    if (movingPhoto === undefined) {
4785      console.error('Error occurred when preparing data');
4786      return;
4787    }
4788    // The URIs must be valid.
4789    let imageFileUri: string = "file://com.example.temptest/data/storage/el2/base/haps/ImageFile.jpg";
4790    try {
4791      await movingPhoto.requestContent(photoAccessHelper.ResourceType.IMAGE_RESOURCE, imageFileUri);
4792      console.log("moving photo image content retrieved successfully");
4793    } catch (err) {
4794      console.error(`failed to retrieve image content of moving photo, error code is ${err.code}, message is ${err.message}`);
4795    }
4796  }
4797}
4798
4799async function example() {
4800  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4801  predicates.equalTo(photoAccessHelper.PhotoKeys.PHOTO_SUBTYPE, photoAccessHelper.PhotoSubtype.MOVING_PHOTO);
4802  let fetchOptions: photoAccessHelper.FetchOptions = {
4803    fetchColumns: [],
4804    predicates: predicates
4805  };
4806  // Ensure that there are moving photos in Gallery.
4807  let assetResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
4808  let asset: photoAccessHelper.PhotoAsset = await assetResult.getFirstObject();
4809  let requestOptions: photoAccessHelper.RequestOptions = {
4810    deliveryMode: photoAccessHelper.DeliveryMode.FAST_MODE,
4811  }
4812  const handler = new MovingPhotoHandler();
4813  try {
4814    let requestId: string = await photoAccessHelper.MediaAssetManager.requestMovingPhoto(context, asset, requestOptions, handler);
4815    console.info("moving photo requested successfully, requestId: " + requestId);
4816  } catch (err) {
4817    console.error(`failed to request moving photo, error code is ${err.code}, message is ${err.message}`);
4818  }
4819}
4820```
4821
4822### requestContent<sup>12+</sup>
4823
4824requestContent(resourceType: ResourceType): Promise\<ArrayBuffer>
4825
4826Requests the moving photo content of the specified resource type and returns it in ArrayBuffer format.
4827
4828**Atomic service API**: This API can be used in atomic services since API version 12.
4829
4830**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4831
4832**Required permissions**: ohos.permission.READ_IMAGEVIDEO
4833
4834- If the application does not have the ohos.permission.READ_IMAGEVIDEO permission, use Picker to call this API to request a moving photo object and read the content. For details, see [Accessing and Managing Moving Photos](../../media/medialibrary/photoAccessHelper-movingphoto.md).
4835- For the moving photos saved to the media library by this application, the application can access them without the ohos.permission.READ_IMAGEVIDEO permission.
4836
4837**Parameters**
4838
4839| Name  | Type                                                                  | Mandatory| Description                     |
4840| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
4841| resourceType | [ResourceType](#resourcetype11)                      | Yes  | Resource type of the moving photo content to request.|
4842
4843**Return value**
4844
4845| Type                                   | Description             |
4846| --------------------------------------- | ----------------- |
4847| Promise\<ArrayBuffer> | Promise used to return the requested content in an ArrayBuffer.|
4848
4849**Error codes**
4850
4851For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
4852
4853| ID| Error Message|
4854| -------- | ---------------------------------------- |
4855| 201      |  Permission denied   |
4856| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4857| 14000011 |  System inner fail         |
4858
4859**Example**
4860
4861```ts
4862import { dataSharePredicates } from '@kit.ArkData';
4863
4864class MovingPhotoHandler implements photoAccessHelper.MediaAssetDataHandler<photoAccessHelper.MovingPhoto> {
4865  async onDataPrepared(movingPhoto: photoAccessHelper.MovingPhoto) {
4866    if (movingPhoto === undefined) {
4867      console.error('Error occurred when preparing data');
4868      return;
4869    }
4870    try {
4871      let buffer: ArrayBuffer = await movingPhoto.requestContent(photoAccessHelper.ResourceType.IMAGE_RESOURCE);
4872      console.log("moving photo image content retrieved successfully, buffer length: " + buffer.byteLength);
4873    } catch (err) {
4874      console.error(`failed to retrieve image content of moving photo, error code is ${err.code}, message is ${err.message}`);
4875    }
4876  }
4877}
4878
4879async function example() {
4880  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4881  predicates.equalTo(photoAccessHelper.PhotoKeys.PHOTO_SUBTYPE, photoAccessHelper.PhotoSubtype.MOVING_PHOTO);
4882  let fetchOptions: photoAccessHelper.FetchOptions = {
4883    fetchColumns: [],
4884    predicates: predicates
4885  };
4886  // Ensure that there are moving photos in Gallery.
4887  let assetResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
4888  let asset: photoAccessHelper.PhotoAsset = await assetResult.getFirstObject();
4889  let requestOptions: photoAccessHelper.RequestOptions = {
4890    deliveryMode: photoAccessHelper.DeliveryMode.FAST_MODE,
4891  }
4892  const handler = new MovingPhotoHandler();
4893  try {
4894    let requestId: string = await photoAccessHelper.MediaAssetManager.requestMovingPhoto(context, asset, requestOptions, handler);
4895    console.info("moving photo requested successfully, requestId: " + requestId);
4896  } catch (err) {
4897    console.error(`failed to request moving photo, error code is ${err.code}, message is ${err.message}`);
4898  }
4899}
4900```
4901
4902## MemberType
4903
4904type MemberType = number | string | boolean
4905
4906Defines the types of the **PhotoAsset** members.
4907
4908The member types are the union of the types listed in the following table.
4909
4910**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4911
4912| Type| Description|
4913| ---- | ---- |
4914| number | The member value is any number.|
4915| string | The member value is any string.|
4916| boolean | The member value is true or false.|
4917
4918## PhotoType
4919
4920Enumerates media file types.
4921
4922**Atomic service API**: This API can be used in atomic services since API version 11.
4923
4924**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4925
4926| Name |  Value|  Description|
4927| ----- |  ---- |  ---- |
4928| IMAGE |  1 |  Image.|
4929| VIDEO |  2 |  Video.|
4930
4931## PhotoSubtype<sup>12+</sup>
4932
4933Enumerates the [PhotoAsset](#photoasset) types.
4934
4935**Atomic service API**: This API can be used in atomic services since API version 12.
4936
4937**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4938
4939| Name |  Value|  Description|
4940| ----- |  ---- |  ---- |
4941| DEFAULT |  0 |  Photo, which is the default type.|
4942| MOVING_PHOTO |  3 |  Moving photo.|
4943| BURST |  4 |  Burst photo.|
4944
4945## DynamicRangeType<sup>12+</sup>
4946
4947Enumerates the formats for displaying media assets.
4948
4949**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4950
4951| Name |  Value|  Description|
4952| ----- |  ---- |  ---- |
4953| SDR |  0 |  Standard dynamic range (SDR).|
4954| HDR |  1 |  High dynamic range (HDR). |
4955
4956## AlbumType
4957
4958Enumerates the album types.
4959
4960**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4961
4962| Name                 | Value   | Description                       |
4963| ------------------- | ---- | ------------------------- |
4964| USER                | 0    | User album.                    |
4965| SYSTEM              | 1024 | System album.                  |
4966
4967## AlbumSubtype
4968
4969Enumerate the album subtypes.
4970
4971**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4972
4973| Name                               | Value         | Description                             |
4974| --------------------------------- | ---------- | ------------------------------- |
4975| USER\_GENERIC                     | 1          | User album.                          |
4976| FAVORITE                          | 1025       | Favorites.                           |
4977| VIDEO                             | 1026       | Video album.                          |
4978| IMAGE<sup>12+</sup>               | 1031       | Photo album.                          |
4979| ANY                               | 2147483647 | Any album.                          |
4980
4981## PhotoKeys
4982
4983Defines the key information about an image or video file.
4984
4985**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
4986
4987| Name         | Value             | Description                                                      |
4988| ------------- | ------------------- | ---------------------------------------------------------- |
4989| 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.           |
4990| PHOTO_TYPE    | 'media_type'           | Type of the file.                                             |
4991| DISPLAY_NAME  | 'display_name'        | File name displayed.                                                  |
4992| SIZE          | 'size'                | File size, in bytes.                                                  |
4993| DATE_ADDED    | 'date_added'          | Date when the file was added. The value is the number of seconds elapsed since the Epoch time (00:00:00 UTC on January 1, 1970).            |
4994| DATE_MODIFIED | 'date_modified'       | Date when the file content (not the file name) was last modified. The value is the number of seconds elapsed since the Epoch time.|
4995| DURATION      | 'duration'            | Duration, in ms.                                   |
4996| WIDTH         | 'width'               | Image width, in pixels.                                   |
4997| HEIGHT        | 'height'              | Image height, in pixels.                                     |
4998| DATE_TAKEN    | 'date_taken'          | Date when the file (photo) was taken. The value is the number of seconds elapsed since the Epoch time.               |
4999| ORIENTATION   | 'orientation'         | Orientation of the file, in degrees.                                            |
5000| FAVORITE      | 'is_favorite'            | Whether the file is added to favorites.                                                   |
5001| TITLE         | 'title'               | Title in the file.                                                  |
5002| DATE_ADDED_MS<sup>12+</sup>  | 'date_added_ms'          | Date when the file was added. The value is the number of milliseconds elapsed since the Epoch time (00:00:00 UTC on January 1, 1970).<br>**NOTE**: The photos queried cannot be sorted based on this field. |
5003| DATE_MODIFIED_MS<sup>12+</sup>  | 'date_modified_ms'    | Date when the album file content (not the album name) was last modified. The value is the number of milliseconds elapsed since the Epoch time.<br>**NOTE**: The photos queried cannot be sorted based on this field.|
5004| PHOTO_SUBTYPE<sup>12+</sup>   | 'subtype'               | Subtype of the media file.                                                  |
5005| DYNAMIC_RANGE_TYPE<sup>12+</sup>   | 'dynamic_range_type'               | Dynamic range type of the media asset.                                                 |
5006| 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.|
5007| BURST_KEY<sup>12+</sup>   | 'burst_key'               | Unique ID of a group of burst photos.|
5008| LCD_SIZE<sup>12+</sup>  | 'lcd_size'  | Width and height of an LCD image, in the format of a **width:height** string.|
5009| THM_SIZE<sup>12+</sup>  | 'thm_size'  | Width and height of a thumbnail image, in the format of a **width:height** string.|
5010| 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.|
5011| DATE_TAKEN_MS<sup>13+</sup>  | 'date_taken_ms'  | Date when the image or video was taken. The value is the number of milliseconds elapsed since the Epoch time.|
5012
5013## AlbumKeys
5014
5015Enumerates the key album attributes.
5016
5017**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5018
5019| Name         | Value             | Description                                                      |
5020| ------------- | ------------------- | ---------------------------------------------------------- |
5021| URI           | 'uri'                 | URI of the album.                                                  |
5022| ALBUM_NAME    | 'album_name'          | Name of the album.                                                  |
5023
5024## CreateOptions
5025
5026Options for creating an image or video asset.
5027
5028The title must meet the following requirements:
5029- It does not contain a file name extension.
5030- The file name cannot exceed 255 characters.
5031- It does not contain any of the following characters:<br> . .. \ / : * ? " ' ` < > | { } [ ]
5032
5033**Atomic service API**: This API can be used in atomic services since API version 11.
5034
5035**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5036
5037| Name                  | Type               | Mandatory| Description                                             |
5038| ---------------------- | ------------------- | ---- | ------------------------------------------------ |
5039| title                  | string                          | No | Title of the image or video. |
5040| 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. |
5041
5042
5043## FetchOptions
5044
5045Defines the options for fetching media files.
5046
5047**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5048
5049| Name                  | Type               | Readable| Writable| Description                                             |
5050| ---------------------- | ------------------- | ---- |---- | ------------------------------------------------ |
5051| 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.|
5052| predicates           | [dataSharePredicates.DataSharePredicates](../apis-arkdata/js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes  | Yes  | Predicates that specify the fetch criteria.|
5053
5054## RequestOptions<sup>11+</sup>
5055
5056Represents request options.
5057
5058**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5059
5060| Name                  | Type                       | Read-Only| Optional| Description                                        |
5061| ---------------------- |----------------------------| ---- | ---- | ------------------------------------------- |
5062| deliveryMode           | [DeliveryMode](#deliverymode11) | No  | No  | Delivery mode of the requested asset. The value can be **FAST_MODE**, **HIGH_QUALITY_MODE**, or **BALANCE_MODE**.|
5063
5064## MediaChangeRequest<sup>11+</sup>
5065
5066Media change request, which is the parent class of the asset change request and album change request.
5067
5068> **NOTE**<br>**MediaChangeRequest** takes effect only after [applyChanges](#applychanges11) is called.
5069
5070**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5071
5072## ResourceType<sup>11+</sup>
5073
5074Enumerates the types of the resources to write.
5075
5076**Atomic service API**: This API can be used in atomic services since API version 11.
5077
5078**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5079
5080| Name |  Value|  Description|
5081| ----- |  ---- |  ---- |
5082| IMAGE_RESOURCE |  1 |  Image resource.|
5083| VIDEO_RESOURCE |  2 |  Video resource.|
5084
5085## ImageFileType<sup>13+</sup>
5086
5087Enumerates the types of image files to save.
5088
5089**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5090
5091| Name |  Value|  Description|
5092| ----- |  ---- |  ---- |
5093| JPEG  |  1 |  JPEG.|
5094| HEIF  |  2 |  HEIF.|
5095
5096## ChangeData
5097
5098Defines the return value of the listener callback.
5099
5100**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5101
5102| Name   | Type                       | Readable| Writable| Description                                                        |
5103| ------- | --------------------------- | ---- | ---- | ------------------------------------------------------------ |
5104| type    | [NotifyType](#notifytype) | Yes  | No  | Notification type.                                      |
5105| uris    | Array&lt;string&gt;         | Yes  | No  | All URIs with the same [NotifyType](#notifytype), which can be **PhotoAsset** or **Album**.|
5106| extraUris | Array&lt;string&gt;         | Yes  | No  | URIs of the changed files in the album.                                   |
5107
5108## NotifyType
5109
5110Enumerates the notification event types.
5111
5112**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5113
5114| Name                     | Value  | Description                            |
5115| ------------------------- | ---- | -------------------------------- |
5116| NOTIFY_ADD                | 0    | A file asset or album is added.    |
5117| NOTIFY_UPDATE             | 1    | A file asset or album is updated.    |
5118| NOTIFY_REMOVE             | 2    | A file asset or album is removed.    |
5119| NOTIFY_ALBUM_ADD_ASSET    | 3    | A file asset is added to the album.|
5120| NOTIFY_ALBUM_REMOVE_ASSET | 4    | A file asset is removed from the album.|
5121
5122## DefaultChangeUri
5123
5124Enumerates the **DefaultChangeUri** subtypes.
5125
5126**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5127
5128| Name             | Value                     | Description                                                        |
5129| ----------------- | ----------------------- | ------------------------------------------------------------ |
5130| 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.|
5131| DEFAULT_ALBUM_URI | 'file://media/PhotoAlbum' | Default album URI, which must be used with **forChildUris{true}** to subscribe to change notifications of all albums.|
5132
5133## PhotoViewMIMETypes
5134
5135Enumerates the media file types that can be selected.
5136
5137**Atomic service API**: This API can be used in atomic services since API version 11.
5138
5139**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5140
5141| Name                                   |  Value| Description      |
5142|---------------------------------------|  ---- |----------|
5143| IMAGE_TYPE                            |  'image/*' | Image.   |
5144| VIDEO_TYPE                            |  'video/*' | Video.   |
5145| IMAGE_VIDEO_TYPE                      |  '\*/*' | Image and video.|
5146| 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. |
5147
5148## RecommendationType<sup>11+</sup>
5149
5150Enumerates the types of recommended images.
5151
5152**Atomic service API**: This API can be used in atomic services since API version 11.
5153
5154**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5155
5156| Name |  Value|  Description|
5157| ----- |  ---- | ---- |
5158| QR_OR_BAR_CODE  |  1 | QR code or barcode.|
5159| QR_CODE |  2 | QR code.|
5160| BAR_CODE |  3 | Barcode.|
5161| ID_CARD |  4 | ID card.|
5162| PROFILE_PICTURE |  5 | Profile.|
5163| PASSPORT<sup>12+</sup> |  6 | passport.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
5164| BANK_CARD<sup>12+</sup> |  7 | Bank card.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
5165| DRIVER_LICENSE<sup>12+</sup> |  8 | Driver license.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
5166| DRIVING_LICENSE<sup>12+</sup> |  9 | Vehicle license<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
5167| 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.|
5168
5169**Example**
5170
5171```ts
5172import { BusinessError } from '@kit.BasicServicesKit';
5173async function example() {
5174  try {
5175    let recommendOptions: photoAccessHelper.RecommendationOptions = {
5176      recommendationType: photoAccessHelper.RecommendationType.ID_CARD
5177    }
5178    let options: photoAccessHelper.PhotoSelectOptions = {
5179      MIMEType: photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE,
5180      maxSelectNumber: 1,
5181      recommendationOptions: recommendOptions
5182    }
5183    let photoPicker = new photoAccessHelper.PhotoViewPicker();
5184    photoPicker.select(options).then((PhotoSelectResult: photoAccessHelper.PhotoSelectResult) => {
5185      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
5186    }).catch((err: BusinessError) => {
5187      console.error(`PhotoViewPicker.select failed with err: ${err.code}, ${err.message}`);
5188    });
5189  } catch (error) {
5190    let err: BusinessError = error as BusinessError;
5191    console.error(`PhotoViewPicker failed with err: ${err.code}, ${err.message}`);
5192  }
5193}
5194```
5195
5196## TextContextInfo<sup>12+</sup>
5197
5198Represents the text information about the recommended images.
5199
5200**Atomic service API**: This API can be used in atomic services since API version 12.
5201
5202**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5203
5204| Name                   | Type               | Mandatory| Description                         |
5205| ----------------------- | ------------------- | ---- | -------------------------------- |
5206| text | string   | No  | Text based on which images are recommended. The text cannot exceed 250 characters.|
5207
5208**Example**
5209
5210```ts
5211import { BusinessError } from '@kit.BasicServicesKit';
5212async function example() {
5213  try {
5214    let textInfo: photoAccessHelper.TextContextInfo = {
5215      text: 'Pandas at Shanghai Wild Zoo'
5216    }
5217    let recommendOptions: photoAccessHelper.RecommendationOptions = {
5218      textContextInfo: textInfo
5219    }
5220    let options: photoAccessHelper.PhotoSelectOptions = {
5221      MIMEType: photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE,
5222      maxSelectNumber: 1,
5223      recommendationOptions: recommendOptions
5224    }
5225    let photoPicker = new photoAccessHelper.PhotoViewPicker();
5226    photoPicker.select(options).then((PhotoSelectResult: photoAccessHelper.PhotoSelectResult) => {
5227      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
5228    }).catch((err: BusinessError) => {
5229      console.error(`PhotoViewPicker.select failed with err: ${err.code}, ${err.message}`);
5230    });
5231  } catch (error) {
5232    let err: BusinessError = error as BusinessError;
5233    console.error(`PhotoViewPicker failed with err: ${err.code}, ${err.message}`);
5234  }
5235}
5236```
5237
5238## RecommendationOptions<sup>11+</sup>
5239
5240Defines the image recommendation options. The image recommendation feature depends on the image data analysis capability, which varies with devices.
5241
5242**Atomic service API**: This API can be used in atomic services since API version 11.
5243
5244**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5245
5246| Name                   | Type               | Mandatory| Description                         |
5247| ----------------------- | ------------------- | ---- | -------------------------------- |
5248| recommendationType | [RecommendationType](#recommendationtype11)   | No  | Type of the recommended image.|
5249| 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.|
5250
5251## BaseSelectOptions<sup>12+</sup>
5252
5253Defines the basic options for selecting media assets from Gallery.
5254
5255**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5256
5257| Name                   | Type               | Mandatory| Description                         |
5258| ----------------------- | ------------------- | ---- | -------------------------------- |
5259| 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.|
5260| 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.  |
5261| 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.|
5262| 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.|
5263| 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.|
5264| 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.|
5265| 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.|
5266
5267## PhotoSelectOptions
5268
5269Defines additional options for selecting media assets from Gallery. It inherits from **BaseSelectOptions**.
5270
5271**Atomic service API**: This API can be used in atomic services since API version 11.
5272
5273**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5274
5275| Name                   | Type               | Mandatory| Description                         |
5276| ----------------------- | ------------------- | ---- | -------------------------------- |
5277| 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.    |
5278| 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.    |
5279| 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.    |
5280| complteButtonText<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.    |
5281
5282## PhotoSelectResult
5283
5284Defines information about the images or videos selected.
5285
5286**Atomic service API**: This API can be used in atomic services since API version 11.
5287
5288**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5289
5290| Name                   | Type               | Readable| Writable| Description                          |
5291| ----------------------- | ------------------- | ---- | ---- | ------------------------------ |
5292| 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).|
5293| isOriginalPhoto        | boolean    | Yes  | Yes  | Whether the selected media asset is the original image.|
5294
5295
5296## DeliveryMode<sup>11+</sup>
5297
5298Enumerates the asset delivery modes.
5299
5300**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5301
5302| Name |  Value|  Description|
5303| ----- |  ---- |  ---- |
5304| FAST_MODE |  0 |  Fast mode.|
5305| HIGH_QUALITY_MODE |  1 |  High-quality mode.|
5306| BALANCE_MODE |  2 |  Balance mode.|
5307
5308## PhotoCreationConfig<sup>12+</sup>
5309
5310Represents the configuration for saving a media asset (image or video) to the media library, including the file name.
5311
5312**Atomic service API**: This API can be used in atomic services since API version 12.
5313
5314**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5315
5316| Name                  | Type               | Mandatory| Description                                             |
5317| ---------------------- | ------------------- | ---- | ------------------------------------------------ |
5318| title | string | No | Title of the image or video.|
5319| fileNameExtension | string | Yes | File name extension, for example, **'jpg'**.|
5320| photoType | [PhotoType](#phototype) | Yes | Type of the file to create, which can be **IMAGE** or **VIDEO**.|
5321| subtype | [PhotoSubtype](#photosubtype12) | No | Subtype of the image or video file, which can be **DEFAULT** or **MOVING_PHOTO**.|
5322
5323## CompleteButtonText<sup>14+</sup>
5324
5325Enumerates the text displayed on the complete button.
5326
5327**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
5328
5329| Name |  Value|  Description|
5330| ----- | ---- | ---- |
5331| TEXT_DONE<sup>14+</sup> |  0 |  The text "Done" is displayed. |
5332| TEXT_SEND<sup>14+</sup>    |  1 |  The text "Send" is displayed.   |
5333| TEXT_ADD<sup>14+</sup> |  2 |  The text "Add" is displayed. |
5334