• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.file.photoAccessHelper (相册管理模块)(系统接口)
2
3该模块提供相册管理模块能力,包括创建相册以及访问、修改相册中的媒体数据信息等。
4
5> **说明:**
6>
7> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8> - 当前页面仅包含本模块的系统接口,其他公开接口参见[@ohos.file.photoAccessHelper (相册管理模块)](js-apis-photoAccessHelper.md)。
9
10## 导入模块
11
12```ts
13import { photoAccessHelper } from '@kit.MediaLibraryKit';
14```
15
16## PhotoAccessHelper
17
18### createAsset
19
20createAsset(displayName: string, callback: AsyncCallback<PhotoAsset>): void
21
22指定待创建的图片或者视频的文件名,创建图片或视频资源,使用callback方式返回结果。
23
24待创建的文件名参数规格为:
25- 应包含有效文件主名和图片或视频扩展名。
26- 文件名字符串长度为1~255。
27- 文件主名中不允许出现的非法英文字符。<br>API18开始,非法字符包括: \ / : * ? " < > | <br>API10-17,非法字符包括:. .. \ / : * ? " ' ` < > | { } [ ]
28
29**系统接口**:此接口为系统接口。
30
31**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
32
33**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
34
35**参数:**
36
37| 参数名   | 类型                     | 必填 | 说明                      |
38| -------- | ------------------------ | ---- | ------------------------- |
39| displayName  | string        | 是   | 创建的图片或者视频文件名。              |
40| callback |  AsyncCallback&lt;[PhotoAsset](#photoasset)&gt; | 是   | callback返回创建的图片和视频结果。 |
41
42**错误码:**
43
44接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
45
46| 错误码ID | 错误信息 |
47| -------- | ---------------------------------------- |
48| 202   |  Called by non-system application.         |
49| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
50| 13900012     | Permission denied.         |
51| 13900020     | Invalid argument.         |
52| 14000001      | Invalid display name.         |
53| 14000011       | System inner fail.         |
54
55**示例:**
56
57```ts
58async function example() {
59  console.info('createAssetDemo');
60  let testFileName: string = 'testFile' + Date.now() + '.jpg';
61  phAccessHelper.createAsset(testFileName, (err, photoAsset) => {
62    if (photoAsset !== undefined) {
63      console.info('createAsset file displayName' + photoAsset.displayName);
64      console.info('createAsset successfully');
65    } else {
66      console.error(`createAsset failed, error: ${err.code}, ${err.message}`);
67    }
68  });
69}
70```
71
72### createAsset
73
74createAsset(displayName: string): Promise&lt;PhotoAsset&gt;
75
76指定待创建的图片或者视频的文件名,创建图片或视频资源,使用Promise方式返回结果。
77
78待创建的文件名参数规格为:
79- 应包含有效文件主名和图片或视频扩展名。
80- 文件名字符串长度为1~255。
81- 文件主名中不允许出现的非法英文字符。<br>API18开始,非法字符包括: \ / : * ? " < > | <br>API10-17,非法字符包括:. .. \ / : * ? " ' ` < > | { } [ ]
82
83**系统接口**:此接口为系统接口。
84
85**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
86
87**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
88
89**参数:**
90
91| 参数名   | 类型                     | 必填 | 说明                      |
92| -------- | ------------------------ | ---- | ------------------------- |
93| displayName  | string        | 是   | 创建的图片或者视频文件名。              |
94
95**返回值:**
96
97| 类型                        | 说明           |
98| --------------------------- | -------------- |
99| Promise&lt;[PhotoAsset](#photoasset)&gt; | Promise对象,返回创建的图片和视频结果。 |
100
101**错误码:**
102
103接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
104
105| 错误码ID | 错误信息 |
106| -------- | ---------------------------------------- |
107| 202   |  Called by non-system application.         |
108| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
109| 13900012     | Permission denied.         |
110| 13900020     | Invalid argument.         |
111| 14000001      | Invalid display name.         |
112| 14000011       | System inner fail.         |
113
114**示例:**
115
116```ts
117async function example() {
118  console.info('createAssetDemo');
119  try {
120    let testFileName: string = 'testFile' + Date.now() + '.jpg';
121    let photoAsset: photoAccessHelper.PhotoAsset = await phAccessHelper.createAsset(testFileName);
122    console.info('createAsset file displayName' + photoAsset.displayName);
123    console.info('createAsset successfully');
124  } catch (err) {
125    console.error(`createAsset failed, error: ${err.code}, ${err.message}`);
126  }
127}
128```
129
130### createAsset
131
132createAsset(displayName: string, options: PhotoCreateOptions, callback: AsyncCallback&lt;PhotoAsset&gt;): void
133
134指定待创建的图片或者视频的文件名和创建选项,创建图片或视频资源,使用callback方式返回结果。
135
136待创建的文件名参数规格为:
137- 应包含有效文件主名和图片或视频扩展名。
138- 文件名字符串长度为1~255。
139- 文件主名中不允许出现的非法英文字符。<br>API18开始,非法字符包括: \ / : * ? " < > | <br>API10-17,非法字符包括:. .. \ / : * ? " ' ` < > | { } [ ]
140
141**系统接口**:此接口为系统接口。
142
143**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
144
145**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
146
147**参数:**
148
149| 参数名   | 类型                     | 必填 | 说明                      |
150| -------- | ------------------------ | ---- | ------------------------- |
151| displayName  | string        | 是   | 创建的图片或者视频文件名。              |
152| options  | [PhotoCreateOptions](#photocreateoptions)        | 是   | 图片或视频的创建选项。              |
153| callback |  AsyncCallback&lt;[PhotoAsset](#photoasset)&gt; | 是   | callback返回创建的图片和视频结果。 |
154
155**错误码:**
156
157接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
158
159| 错误码ID | 错误信息 |
160| -------- | ---------------------------------------- |
161| 202   |  Called by non-system application.         |
162| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
163| 13900012     | Permission denied.         |
164| 13900020     | Invalid argument.         |
165| 14000001      | Invalid display name.         |
166| 14000011       | System inner fail.         |
167
168**示例:**
169
170```ts
171async function example() {
172  console.info('createAssetDemo');
173  let testFileName: string = 'testFile' + Date.now() + '.jpg';
174  let createOption: photoAccessHelper.PhotoCreateOptions = {
175    subtype: photoAccessHelper.PhotoSubtype.DEFAULT
176  }
177  phAccessHelper.createAsset(testFileName, createOption, (err, photoAsset) => {
178    if (photoAsset !== undefined) {
179      console.info('createAsset file displayName' + photoAsset.displayName);
180      console.info('createAsset successfully');
181    } else {
182      console.error(`createAsset failed, error: ${err.code}, ${err.message}`);
183    }
184  });
185}
186```
187
188### createAsset
189
190createAsset(displayName: string, options: PhotoCreateOptions): Promise&lt;PhotoAsset&gt;
191
192指定待创建的图片或者视频的文件名和创建选项,创建图片或视频资源,使用Promise方式返回结果。
193
194待创建的文件名参数规格为:
195- 应包含有效文件主名和图片或视频扩展名。
196- 文件名字符串长度为1~255。
197- 文件主名中不允许出现的非法英文字符。<br>API18开始,非法字符包括: \ / : * ? " < > | <br>API10-17,非法字符包括:. .. \ / : * ? " ' ` < > | { } [ ]
198
199**系统接口**:此接口为系统接口。
200
201**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
202
203**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
204
205**参数:**
206
207| 参数名   | 类型                     | 必填 | 说明                      |
208| -------- | ------------------------ | ---- | ------------------------- |
209| displayName  | string        | 是   | 创建的图片或者视频文件名。              |
210| options  |  [PhotoCreateOptions](#photocreateoptions)       | 是   | 图片或视频的创建选项。              |
211
212**返回值:**
213
214| 类型                        | 说明           |
215| --------------------------- | -------------- |
216| Promise&lt;[PhotoAsset](#photoasset)&gt; | Promise对象,返回创建的图片和视频结果。 |
217
218**错误码:**
219
220接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
221
222| 错误码ID | 错误信息 |
223| -------- | ---------------------------------------- |
224| 202   |  Called by non-system application.         |
225| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
226| 13900012     | Permission denied.         |
227| 13900020     | Invalid argument.         |
228| 14000001      | Invalid display name.         |
229| 14000011       | System inner fail.         |
230
231**示例:**
232
233```ts
234async function example() {
235  console.info('createAssetDemo');
236  try {
237    let testFileName:string = 'testFile' + Date.now() + '.jpg';
238    let createOption: photoAccessHelper.PhotoCreateOptions = {
239      subtype: photoAccessHelper.PhotoSubtype.DEFAULT
240    }
241    let photoAsset: photoAccessHelper.PhotoAsset = await phAccessHelper.createAsset(testFileName, createOption);
242    console.info('createAsset file displayName' + photoAsset.displayName);
243    console.info('createAsset successfully');
244  } catch (err) {
245    console.error(`createAsset failed, error: ${err.code}, ${err.message}`);
246  }
247}
248```
249
250### createAlbum<sup>(deprecated)</sup>
251
252createAlbum(name: string, callback: AsyncCallback&lt;Album&gt;): void
253
254创建相册,使用callback方式返回结果。
255
256待创建的相册名参数规格为:
257- 相册名字符串长度为1~255。
258- 不允许出现的非法英文字符,包括:<br> . .. \ / : * ? " ' ` < > | { } [ ]
259- 英文字符大小写不敏感。
260- 相册名不允许重名。
261
262> **说明:**
263>
264> 从API version 10开始支持,从API version 11开始废弃。建议使用[MediaAlbumChangeRequest.createAlbumRequest](#createalbumrequest11)替代。
265
266**系统接口**:此接口为系统接口。
267
268**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
269
270**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
271
272**参数:**
273
274| 参数名   | 类型                     | 必填 | 说明                      |
275| -------- | ------------------------ | ---- | ------------------------- |
276| name  | string         | 是   | 待创建相册的相册名。              |
277| callback |  AsyncCallback&lt;[Album](#album)&gt; | 是   | callback返回创建的相册实例。 |
278
279**错误码:**
280
281接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
282
283| 错误码ID | 错误信息 |
284| -------- | ---------------------------------------- |
285| 202   |  Called by non-system application.         |
286| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
287| 13900012     | Permission denied.         |
288| 13900015       |  File exists.         |
289| 13900020     | Invalid argument.         |
290| 14000011       | System inner fail.         |
291
292**示例:**
293
294```ts
295async function example() {
296  console.info('createAlbumDemo');
297  let albumName: string = 'newAlbumName' + new Date().getTime();
298  phAccessHelper.createAlbum(albumName, (err, album) => {
299    if (err) {
300      console.error(`createAlbumCallback failed with err: ${err.code}, ${err.message}`);
301      return;
302    }
303    console.info('createAlbumCallback successfully, album: ' + album.albumName + ' album uri: ' + album.albumUri);
304  });
305}
306```
307
308### createAlbum<sup>(deprecated)</sup>
309
310createAlbum(name: string): Promise&lt;Album&gt;
311
312创建相册,使用Promise方式返回结果。
313
314待创建的相册名参数规格为:
315- 相册名字符串长度为1~255。
316- 不允许出现的非法英文字符,包括:<br> . .. \ / : * ? " ' ` < > | { } [ ]
317- 英文字符大小写不敏感。
318- 相册名不允许重名。
319
320> **说明:**
321>
322> 从API version 10开始支持,从API version 11开始废弃。建议使用[MediaAlbumChangeRequest.createAlbumRequest](#createalbumrequest11)替代。
323
324**系统接口**:此接口为系统接口。
325
326**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
327
328**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
329
330**参数:**
331
332| 参数名   | 类型                     | 必填 | 说明                      |
333| -------- | ------------------------ | ---- | ------------------------- |
334| name  | string         | 是   | 待创建相册的相册名。              |
335
336**返回值:**
337
338| 类型                        | 说明           |
339| --------------------------- | -------------- |
340| Promise&lt;[Album](#album)&gt; | Promise对象,返回创建的相册实例。 |
341
342**错误码:**
343
344接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
345
346| 错误码ID | 错误信息 |
347| -------- | ---------------------------------------- |
348| 202   |  Called by non-system application.         |
349| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
350| 13900012     | Permission denied.         |
351| 13900015       |  File exists.         |
352| 13900020     | Invalid argument.         |
353| 14000011       | System inner fail.         |
354
355**示例:**
356
357```ts
358import { BusinessError } from '@kit.BasicServicesKit';
359
360async function example() {
361  console.info('createAlbumDemo');
362  let albumName: string = 'newAlbumName' + new Date().getTime();
363  phAccessHelper.createAlbum(albumName).then((album) => {
364    console.info('createAlbumPromise successfully, album: ' + album.albumName + ' album uri: ' + album.albumUri);
365  }).catch((err: BusinessError) => {
366    console.error(`createAlbumPromise failed with err: ${err.code}, ${err.message}`);
367  });
368}
369```
370
371### deleteAlbums<sup>(deprecated)</sup>
372
373deleteAlbums(albums: Array&lt;Album&gt;, callback: AsyncCallback&lt;void&gt;): void
374
375删除相册,使用callback方式返回结果。
376
377删除相册前需先确保相册存在,只能删除用户相册。
378
379> **说明:**
380>
381> 从API version 10开始支持,从API version 11开始废弃。建议使用[MediaAlbumChangeRequest.deleteAlbums](#deletealbums11)替代。
382
383**系统接口**:此接口为系统接口。
384
385**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
386
387**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
388
389**参数:**
390
391| 参数名   | 类型                     | 必填 | 说明                      |
392| -------- | ------------------------ | ---- | ------------------------- |
393| albums  | Array&lt;[Album](#album)&gt;         | 是   | 待删除相册的数组。              |
394| callback |  AsyncCallback&lt;void&gt; | 是   | callback返回void。 |
395
396**错误码:**
397
398接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
399
400| 错误码ID | 错误信息 |
401| -------- | ---------------------------------------- |
402| 202   |  Called by non-system application.         |
403| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
404| 13900012     | Permission denied.         |
405| 13900020     | Invalid argument.         |
406| 14000011       | System inner fail.         |
407
408**示例:**
409
410```ts
411import { dataSharePredicates } from '@kit.ArkData';
412
413async function example() {
414  // 示例代码为删除相册名为newAlbumName的相册。
415  console.info('deleteAlbumsDemo');
416  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
417  predicates.equalTo('album_name', 'newAlbumName');
418  let fetchOptions: photoAccessHelper.FetchOptions = {
419    fetchColumns: [],
420    predicates: predicates
421  };
422  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions);
423  let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
424  phAccessHelper.deleteAlbums([album], (err) => {
425    if (err) {
426      console.error(`deletePhotoAlbumsCallback failed with err: ${err.code}, ${err.message}`);
427      return;
428    }
429    console.info('deletePhotoAlbumsCallback successfully');
430  });
431  fetchResult.close();
432}
433```
434
435### deleteAlbums<sup>(deprecated)</sup>
436
437deleteAlbums(albums: Array&lt;Album&gt;): Promise&lt;void&gt;
438
439删除相册,使用Promise方式返回结果。
440
441删除相册前需先确保相册存在,只能删除用户相册。
442
443> **说明:**
444>
445> 从API version 10开始支持,从API version 11开始废弃。建议使用[MediaAlbumChangeRequest.deleteAlbums](#deletealbums11)替代。
446
447**系统接口**:此接口为系统接口。
448
449**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
450
451**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
452
453**参数:**
454
455| 参数名   | 类型                     | 必填 | 说明                      |
456| -------- | ------------------------ | ---- | ------------------------- |
457| albums  |  Array&lt;[Album](#album)&gt;          | 是   | 待删除相册的数组。              |
458
459**返回值:**
460
461| 类型                        | 说明           |
462| --------------------------- | -------------- |
463| Promise&lt;void&gt; | Promise对象,返回void。 |
464
465**错误码:**
466
467接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
468
469| 错误码ID | 错误信息 |
470| -------- | ---------------------------------------- |
471| 202   |  Called by non-system application.         |
472| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
473| 13900012     | Permission denied.         |
474| 13900020     | Invalid argument.         |
475| 14000011       | System inner fail.         |
476
477**示例:**
478
479```ts
480import { dataSharePredicates } from '@kit.ArkData';
481import { BusinessError } from '@kit.BasicServicesKit';
482
483async function example() {
484  // 示例代码为删除相册名为newAlbumName的相册。
485  console.info('deleteAlbumsDemo');
486  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
487  predicates.equalTo('album_name', 'newAlbumName');
488  let fetchOptions: photoAccessHelper.FetchOptions = {
489    fetchColumns: [],
490    predicates: predicates
491  };
492  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions);
493  let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
494  phAccessHelper.deleteAlbums([album]).then(() => {
495    console.info('deletePhotoAlbumsPromise successfully');
496    }).catch((err: BusinessError) => {
497      console.error(`deletePhotoAlbumsPromise failed with err: ${err.code}, ${err.message}`);
498  });
499  fetchResult.close();
500}
501```
502
503### getHiddenAlbums<sup>11+</sup>
504
505getHiddenAlbums(mode: HiddenPhotosDisplayMode, options: FetchOptions, callback: AsyncCallback&lt;FetchResult&lt;Album&gt;&gt;): void
506
507根据隐藏文件显示模式和检索选项获取系统中的隐藏相册,使用callback方式返回结果。
508
509**系统接口**:此接口为系统接口。
510
511**需要权限**:ohos.permission.READ_IMAGEVIDEOohos.permission.MANAGE_PRIVATE_PHOTOS
512
513**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
514
515**参数:**
516
517| 参数名   | 类型                     | 必填 | 说明                      |
518| -------- | ------------------------ | ---- | ------------------------- |
519| mode  | [HiddenPhotosDisplayMode](#hiddenphotosdisplaymode11)         | 是   | 隐藏文件显示模式。  |
520| options  | [FetchOptions](js-apis-photoAccessHelper.md#fetchoptions)         | 是   |  检索选项。  |
521| callback |  AsyncCallback&lt;[FetchResult](js-apis-photoAccessHelper.md#fetchresult)&lt;[Album](#album)&gt;&gt; | 是  callback返回获取相册的结果集。 |
522
523**错误码:**
524
525接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
526
527| 错误码ID | 错误信息 |
528| -------- | ---------------------------------------- |
529| 201      |  Permission verification failed, usually the result returned by VerifyAccessToken.         |
530| 202      |  Permission verification failed, application which is not a system application uses system API.         |
531| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
532| 14000011       | System inner fail.         |
533
534**示例:**
535
536```ts
537import { dataSharePredicates } from '@kit.ArkData';
538
539// 获取系统中包含隐藏文件且相册名为'newAlbumName'的相册
540async function getHiddenAlbumsView() {
541  console.info('getHiddenAlbumsViewDemo');
542  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
543  predicates.equalTo('album_name', 'newAlbumName');
544  let fetchOptions: photoAccessHelper.FetchOptions = {
545    fetchColumns: [],
546    predicates: predicates
547  };
548  phAccessHelper.getHiddenAlbums(photoAccessHelper.HiddenPhotosDisplayMode.ALBUMS_MODE, fetchOptions,
549    async (err, fetchResult) => {
550      if (fetchResult === undefined) {
551        console.error('getHiddenAlbumsViewCallback fetchResult is undefined');
552        return;
553      }
554      let album = await fetchResult.getFirstObject();
555      console.info('getHiddenAlbumsViewCallback successfully, album name: ' + album.albumName);
556      fetchResult.close();
557  });
558}
559```
560
561### getHiddenAlbums<sup>11+</sup>
562
563getHiddenAlbums(mode: HiddenPhotosDisplayMode, callback: AsyncCallback&lt;FetchResult&lt;Album&gt;&gt;): void
564
565根据隐藏文件显示模式获取系统中的隐藏相册,使用callback方式返回结果
566
567**系统接口**:此接口为系统接口。
568
569**需要权限**:ohos.permission.READ_IMAGEVIDEOohos.permission.MANAGE_PRIVATE_PHOTOS
570
571**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
572
573**参数:**
574
575| 参数名   | 类型                     | 必填 | 说明                      |
576| -------- | ------------------------ | ---- | ------------------------- |
577| mode  | [HiddenPhotosDisplayMode](#hiddenphotosdisplaymode11)         | 是   | 隐藏文件显示模式。  |
578| callback |  AsyncCallback&lt;[FetchResult](js-apis-photoAccessHelper.md#fetchresult)&lt;[Album](#album)&gt;&gt; | 是   | callback返回获取相册的结果集。 |
579
580**错误码:**
581
582接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
583
584| 错误码ID | 错误信息 |
585| -------- | ---------------------------------------- |
586| 201      |  Permission verification failed, usually the result returned by VerifyAccessToken.         |
587| 202      |  Permission verification failed, application which is not a system application uses system API.         |
588| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
589| 14000011       | System inner fail.         |
590
591**示例:**
592
593```ts
594import { dataSharePredicates } from '@kit.ArkData';
595
596// 获取系统预置的隐藏相册
597async function getSysHiddenAlbum() {
598  console.info('getSysHiddenAlbumDemo');
599  phAccessHelper.getHiddenAlbums(photoAccessHelper.HiddenPhotosDisplayMode.ASSETS_MODE, async (err, fetchResult) => {
600    if (fetchResult === undefined) {
601      console.error('getSysHiddenAlbumCallback fetchResult is undefined');
602      return;
603    }
604    let hiddenAlbum: photoAccessHelper.Album = await fetchResult.getFirstObject();
605    console.info('getSysHiddenAlbumCallback successfully, albumUri: ' + hiddenAlbum.albumUri);
606    fetchResult.close();
607  });
608}
609
610// 获取隐藏相册-相册视图,即系统中包含隐藏文件的相册(不包含系统预置的隐藏相册本身和回收站相册)
611async function getHiddenAlbumsView() {
612  console.info('getHiddenAlbumsViewDemo');
613  phAccessHelper.getHiddenAlbums(photoAccessHelper.HiddenPhotosDisplayMode.ALBUMS_MODE, async (err, fetchResult) => {
614    if (fetchResult === undefined) {
615      console.error('getHiddenAlbumsViewCallback fetchResult is undefined');
616      return;
617    }
618    let albums: Array<photoAccessHelper.Album> = await fetchResult.getAllObjects();
619    console.info('getHiddenAlbumsViewCallback successfully, albums size: ' + albums.length);
620
621    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
622    let fetchOption: photoAccessHelper.FetchOptions = {
623      fetchColumns: [],
624      predicates: predicates
625    };
626    for (let i = 0; i < albums.length; i++) {
627      // 获取相册中的隐藏文件。
628      albums[i].getAssets(fetchOption, (err, assetFetchResult) => {
629        console.info('album get hidden assets successfully, getCount: ' + assetFetchResult.getCount());
630      });
631    }
632    fetchResult.close();
633  });
634}
635```
636
637### getHiddenAlbums<sup>11+</sup>
638
639getHiddenAlbums(mode: HiddenPhotosDisplayMode, options?: FetchOptions): Promise&lt;FetchResult&lt;Album&gt;&gt;
640
641根据隐藏文件显示模式和检索选项获取系统中的隐藏相册,使用Promise方式返回结果。
642
643**系统接口**:此接口为系统接口。
644
645**需要权限**:ohos.permission.READ_IMAGEVIDEOohos.permission.MANAGE_PRIVATE_PHOTOS
646
647**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
648
649**参数:**
650
651| 参数名   | 类型                     | 必填 | 说明                      |
652| -------- | ------------------------ | ---- | ------------------------- |
653| mode  | [HiddenPhotosDisplayMode](#hiddenphotosdisplaymode11)         | 是   | 隐藏文件显示模式。  |
654| options  | [FetchOptions](js-apis-photoAccessHelper.md#fetchoptions)         | 否   |  检索选项,不填时默认根据隐藏文件显示模式检索。      |
655
656**返回值:**
657
658| 类型                        | 说明           |
659| --------------------------- | -------------- |
660| Promise&lt;[FetchResult](js-apis-photoAccessHelper.md#fetchresult)&lt;[Album](#album)&gt;&gt; | Promise对象,返回获取相册的结果集。
661
662**错误码:**
663
664接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
665
666| 错误码ID | 错误信息 |
667| -------- | ---------------------------------------- |
668| 201      |  Permission verification failed, usually the result returned by VerifyAccessToken.         |
669| 202      |  Permission verification failed, application which is not a system application uses system API.         |
670| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
671| 14000011       | System inner fail.         |
672
673**示例:**
674
675```ts
676import { dataSharePredicates } from '@kit.ArkData';
677import { BusinessError } from '@kit.BasicServicesKit';
678
679// 获取系统预置的隐藏相册
680async function getSysHiddenAlbum() {
681  console.info('getSysHiddenAlbumDemo');
682  phAccessHelper.getHiddenAlbums(photoAccessHelper.HiddenPhotosDisplayMode.ASSETS_MODE)
683    .then( async (fetchResult) => {
684      if (fetchResult === undefined) {
685        console.error('getSysHiddenAlbumPromise fetchResult is undefined');
686        return;
687      }
688      let hiddenAlbum: photoAccessHelper.Album = await fetchResult.getFirstObject();
689      console.info('getAlbumsPromise successfully, albumUri: ' + hiddenAlbum.albumUri);
690      fetchResult.close();
691    }).catch((err: BusinessError) => {
692      console.error(`getSysHiddenAlbumPromise failed with err: ${err.code}, ${err.message}`);
693    });
694}
695
696// 获取隐藏相册-相册视图,即系统中包含隐藏文件的相册(不包含系统预置的隐藏相册本身和回收站相册)
697async function getHiddenAlbumsView() {
698  console.info('getHiddenAlbumsViewDemo');
699  phAccessHelper.getHiddenAlbums(photoAccessHelper.HiddenPhotosDisplayMode.ALBUMS_MODE).then( async (fetchResult) => {
700    if (fetchResult === undefined) {
701      console.error('getHiddenAlbumsViewPromise fetchResult is undefined');
702      return;
703    }
704    let albums: Array<photoAccessHelper.Album> = await fetchResult.getAllObjects();
705    console.info('getHiddenAlbumsViewPromise successfully, albums size: ' + albums.length);
706
707    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
708    let fetchOption: photoAccessHelper.FetchOptions = {
709      fetchColumns: [],
710      predicates: predicates
711    };
712    for (let i = 0; i < albums.length; i++) {
713      // 获取相册中的隐藏文件。
714      albums[i].getAssets(fetchOption).then((assetFetchResult) => {
715        console.info('album get hidden assets successfully, getCount: ' + assetFetchResult.getCount());
716      }).catch((err: BusinessError) => {
717        console.error(`album get hidden assets failed with error: ${err.code}, ${err.message}`);
718      });
719    }
720    fetchResult.close();
721  }).catch((err: BusinessError) => {
722    console.error(`getHiddenAlbumsViewPromise failed with err: ${err.code}, ${err.message}`);
723  });
724}
725```
726
727### deleteAssets<sup>(deprecated)</sup>
728
729deleteAssets(uriList: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void
730
731删除媒体文件,删除的文件进入到回收站,使用callback方式返回结果。
732
733> **说明:**
734>
735> 从API version 10开始支持,从API version 11开始废弃。建议使用[MediaAssetChangeRequest.deleteAssets](js-apis-photoAccessHelper.md#deleteassets11)替代。
736
737**系统接口**:此接口为系统接口。
738
739**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
740
741**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
742
743**参数:**
744
745| 参数名   | 类型                      | 必填 | 说明       |
746| -------- | ------------------------- | ---- | ---------- |
747| uriList | Array&lt;string&gt; | 是   | 待删除的媒体文件uri数组。 |
748| callback | AsyncCallback&lt;void&gt; | 是   | callback返回void。 |
749
750**错误码:**
751
752接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
753
754| 错误码ID | 错误信息 |
755| -------- | ---------------------------------------- |
756| 202   |  Called by non-system application.         |
757| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
758| 13900012     | Permission denied.         |
759| 13900020     | Invalid argument.         |
760| 14000002       | Invalid uri.         |
761| 14000011       | System inner fail.         |
762
763**示例:**
764
765```ts
766import { dataSharePredicates } from '@kit.ArkData';
767
768async function example() {
769  console.info('deleteAssetDemo');
770  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
771  let fetchOptions: photoAccessHelper.FetchOptions = {
772    fetchColumns: [],
773    predicates: predicates
774  };
775  try {
776    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
777    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
778    if (asset === undefined) {
779      console.error('asset not exist');
780      return;
781    }
782    phAccessHelper.deleteAssets([asset.uri], (err) => {
783      if (err === undefined) {
784        console.info('deleteAssets successfully');
785      } else {
786        console.error(`deleteAssets failed with error: ${err.code}, ${err.message}`);
787      }
788    });
789  } catch (err) {
790    console.error(`fetch failed, error: ${err.code}, ${err.message}`);
791  }
792}
793```
794
795### deleteAssets<sup>(deprecated)</sup>
796
797deleteAssets(uriList: Array&lt;string&gt;): Promise&lt;void&gt;
798
799删除媒体文件,删除的文件进入到回收站,使用Promise方式返回结果。
800
801> **说明:**
802>
803> 从API version 10开始支持,从API version 11开始废弃。建议使用[MediaAssetChangeRequest.deleteAssets](js-apis-photoAccessHelper.md#deleteassets11)替代。
804
805**系统接口**:此接口为系统接口。
806
807**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
808
809**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
810
811**参数:**
812
813| 参数名   | 类型                      | 必填 | 说明       |
814| -------- | ------------------------- | ---- | ---------- |
815| uriList | Array&lt;string&gt; | 是   | 待删除的媒体文件uri数组。 |
816
817**返回值:**
818
819| 类型                                    | 说明              |
820| --------------------------------------- | ----------------- |
821| Promise&lt;void&gt;| Promise对象,返回void。 |
822
823**错误码:**
824
825接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
826
827| 错误码ID | 错误信息 |
828| -------- | ---------------------------------------- |
829| 202   |  Called by non-system application.         |
830| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
831| 13900012     | Permission denied.         |
832| 13900020     | Invalid argument.         |
833| 14000002       | Invalid uri.         |
834| 14000011       | System inner fail.         |
835
836**示例:**
837
838```ts
839import { dataSharePredicates } from '@kit.ArkData';
840
841async function example() {
842  console.info('deleteDemo');
843  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
844  let fetchOptions: photoAccessHelper.FetchOptions = {
845    fetchColumns: [],
846    predicates: predicates
847  };
848  try {
849    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
850    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
851    if (asset === undefined) {
852      console.error('asset not exist');
853      return;
854    }
855    await phAccessHelper.deleteAssets([asset.uri]);
856    console.info('deleteAssets successfully');
857  } catch (err) {
858    console.error(`deleteAssets failed with error: ${err.code}, ${err.message}`);
859  }
860}
861```
862
863### getPhotoIndex
864
865getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions, callback: AsyncCallback&lt;number&gt;): void
866
867获取相册中图片或视频的位置,使用callback方式返回结果。
868
869**系统接口**:此接口为系统接口。
870
871**需要权限**:ohos.permission.READ_IMAGEVIDEO
872
873**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
874
875**参数:**
876
877| 参数名   | 类型                      | 必填 | 说明       |
878| -------- | ------------------------- | ---- | ---------- |
879| photoUri | string | 是   | 所查询的图库资源的uri。 |
880| albumUri | string | 是   | 相册uri,可以为空字符串,为空字符串时默认查询全部图库资源。   |
881| options  | [FetchOptions](js-apis-photoAccessHelper.md#fetchoptions)       | 是   |  检索选项,predicates中必须设置一种检索排序方式,不设置或多设置均会导致接口调用异常。      |
882| callback | AsyncCallback&lt;number&gt;| 是   | callback返回相册中资源的索引。 |
883
884**错误码:**
885
886接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
887
888| 错误码ID | 错误信息 |
889| -------- | ---------------------------------------- |
890| 202     |  Called by non-system application.         |
891| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
892| 13900012     | Permission denied.         |
893| 13900020     | Invalid argument.         |
894| 14000011       | System inner fail.         |
895
896**示例:**
897
898```ts
899import { dataSharePredicates } from '@kit.ArkData';
900
901async function example() {
902  try {
903    console.info('getPhotoIndexDemo');
904    let predicatesForGetAsset: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
905    let fetchOp: photoAccessHelper.FetchOptions = {
906      fetchColumns: [],
907      predicates: predicatesForGetAsset
908    };
909    // Obtain the uri of the album.
910    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.FAVORITE, fetchOp);
911    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
912    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
913    predicates.orderByAsc(photoAccessHelper.PhotoKeys.DATE_MODIFIED);
914    let fetchOptions: photoAccessHelper.FetchOptions = {
915      fetchColumns: [photoAccessHelper.PhotoKeys.DATE_MODIFIED],
916      predicates: predicates
917    };
918    let photoFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions);
919    let expectIndex = 1;
920    // Obtain the uri of the second file.
921    let photoAsset: photoAccessHelper.PhotoAsset = await photoFetchResult.getObjectByPosition(expectIndex);
922
923    phAccessHelper.getPhotoIndex(photoAsset.uri, album.albumUri, fetchOptions, (err, index) => {
924      if (err === undefined) {
925        console.info(`getPhotoIndex successfully and index is : ${index}`);
926      } else {
927        console.error(`getPhotoIndex failed; error: ${err.code}, ${err.message}`);
928      }
929    });
930  } catch (error) {
931    console.error(`getPhotoIndex failed; error: ${error.code}, ${error.message}`);
932  }
933}
934```
935
936### getPhotoIndex
937
938getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions): Promise&lt;number&gt;
939
940获取相册中图片或视频的位置,使用Promise方式返回结果。
941
942**系统接口**:此接口为系统接口。
943
944**需要权限**:ohos.permission.READ_IMAGEVIDEO
945
946**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
947
948**参数:**
949
950| 参数名   | 类型                      | 必填 | 说明       |
951| -------- | ------------------------- | ---- | ---------- |
952| photoUri | string | 是   | 所查询的图库资源的uri。 |
953| albumUri | string | 是   | 相册uri,可以为空字符串,为空字符串时默认查询全部图库资源。   |
954| options  | [FetchOptions](js-apis-photoAccessHelper.md#fetchoptions)       | 是   |  检索选项,predicates中必须设置一种检索排序方式,不设置或多设置均会导致接口调用异常。      |
955
956**返回值:**
957
958| 类型                                    | 说明              |
959| --------------------------------------- | ----------------- |
960| Promise&lt;number&gt;| 返回相册中资源的索引。 |
961
962**错误码:**
963
964接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
965
966| 错误码ID | 错误信息 |
967| -------- | ---------------------------------------- |
968| 202     |  Called by non-system application.         |
969| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
970| 13900012     | Permission denied.         |
971| 13900020     | Invalid argument.         |
972| 14000011       | System inner fail.         |
973
974**示例:**
975
976```ts
977import { dataSharePredicates } from '@kit.ArkData';
978import { BusinessError } from '@kit.BasicServicesKit';
979
980async function example() {
981  try {
982    console.info('getPhotoIndexDemo');
983    let predicatesForGetAsset: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
984    let fetchOp: photoAccessHelper.FetchOptions = {
985      fetchColumns: [],
986      predicates: predicatesForGetAsset
987    };
988    // Obtain the uri of the album.
989    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.FAVORITE, fetchOp);
990    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
991    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
992    predicates.orderByAsc(photoAccessHelper.PhotoKeys.DATE_MODIFIED);
993    let fetchOptions: photoAccessHelper.FetchOptions = {
994      fetchColumns: [photoAccessHelper.PhotoKeys.DATE_MODIFIED],
995      predicates: predicates
996    };
997    let photoFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions);
998    let expectIndex = 1;
999    // Obtain the uri of the second file.
1000    let photoAsset: photoAccessHelper.PhotoAsset = await photoFetchResult.getObjectByPosition(expectIndex);
1001    phAccessHelper.getPhotoIndex(photoAsset.uri, album.albumUri, fetchOptions).then((index) => {
1002      console.info(`getPhotoIndex successfully and index is : ${index}`);
1003    }).catch((err: BusinessError) => {
1004      console.error(`getPhotoIndex failed; error: ${err.code}, ${err.message}`);
1005    });
1006  } catch (error) {
1007    console.error(`getPhotoIndex failed; error: ${error.code}, ${error.message}`);
1008  }
1009}
1010```
1011
1012### saveFormInfo<sup>11+</sup>
1013
1014saveFormInfo(info:FormInfo, callback: AsyncCallback&lt;void&gt;):void
1015
1016将图库卡片相关信息保存到数据库中,使用callback方式返回结果。
1017
1018**系统接口**:此接口为系统接口。
1019
1020**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
1021
1022**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
1023
1024**参数:**
1025
1026| 参数名   | 类型                     | 必填 | 说明                      |
1027| -------- | ------------------------ | ---- | ------------------------- |
1028| info  | [FormInfo](#forminfo11)        | 是   | 图库卡片信息,包括图库卡片的id和卡片绑定的图片的uri。              |
1029| callback |  AsyncCallback&lt;void&gt; | 是   | callback返回void。 |
1030
1031**错误码:**
1032
1033接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
1034
1035| 错误码ID | 错误信息 |
1036| -------- | ---------------------------------------- |
1037| 201   | Permission verification failed, usually the result returned by VerifyAccessToken.         |
1038| 202   | Permission verification failed, application which is not a system application uses system API.         |
1039| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1040| 14000011       | System inner fail.         |
1041
1042
1043**示例:**
1044
1045```ts
1046import { dataSharePredicates } from '@kit.ArkData';
1047import { BusinessError } from '@kit.BasicServicesKit';
1048
1049async function example() {
1050  console.info('saveFormInfoDemo');
1051  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1052  let fetchOptions: photoAccessHelper.FetchOptions = {
1053    fetchColumns: [],
1054    predicates: predicates
1055  };
1056  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1057  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1058
1059  let info: photoAccessHelper.FormInfo = {
1060    //formId是一个由纯数字组成的字符串,uri为图库中存在的图片的uri信息,图库中无图片创建卡片时uri需为空字符串。
1061    formId : "20230116123",
1062    uri: photoAsset.uri,
1063  }
1064
1065  phAccessHelper.saveFormInfo(info, async (err: BusinessError) => {
1066    if (err == undefined) {
1067      console.info('saveFormInfo success');
1068    } else {
1069      console.error(`saveFormInfo fail with error: ${err.code}, ${err.message}`);
1070    }
1071  });
1072}
1073```
1074
1075### saveFormInfo<sup>11+</sup>
1076
1077saveFormInfo(info:FormInfo):Promise&lt;void&gt;
1078
1079将图库卡片相关信息保存到数据库中,使用Promise方式返回结果。
1080
1081**系统接口**:此接口为系统接口。
1082
1083**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
1084
1085**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
1086
1087**参数:**
1088
1089| 参数名   | 类型                     | 必填 | 说明                      |
1090| -------- | ------------------------ | ---- | ------------------------- |
1091| info  | [FormInfo](#forminfo11)        | 是   | 图库卡片信息,包括图库卡片的id和卡片绑定的图片的uri。              |
1092
1093**返回值:**
1094
1095| 类型                                    | 说明              |
1096| --------------------------------------- | ----------------- |
1097| Promise&lt;void&gt;| Promise对象,返回void。 |
1098
1099**错误码:**
1100
1101接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
1102
1103| 错误码ID | 错误信息 |
1104| -------- | ---------------------------------------- |
1105| 201   | Permission verification failed, usually the result returned by VerifyAccessToken.         |
1106| 202   | Permission verification failed, application which is not a system application uses system API.         |
1107| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1108| 14000011       | System inner fail.         |
1109
1110**示例:**
1111
1112```ts
1113import { dataSharePredicates } from '@kit.ArkData';
1114import { BusinessError } from '@kit.BasicServicesKit';
1115
1116async function example() {
1117  console.info('saveFormInfoDemo');
1118  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1119  let fetchOptions: photoAccessHelper.FetchOptions = {
1120    fetchColumns: [],
1121    predicates: predicates
1122  };
1123  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1124  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1125
1126  let info: photoAccessHelper.FormInfo = {
1127    //formId是一个由纯数字组成的字符串,uri为图库中存在的图片的uri信息,图库中无图片创建卡片时uri需为空字符串。
1128    formId: "20230116123",
1129    uri: photoAsset.uri,
1130  }
1131
1132  phAccessHelper.saveFormInfo(info).then(() => {
1133    console.info('saveFormInfo successfully');
1134  }).catch((err: BusinessError) => {
1135    console.error(`saveFormInfo failed with error: ${err.code}, ${err.message}`);
1136  });
1137}
1138```
1139
1140### removeFormInfo<sup>11+</sup>
1141
1142removeFormInfo(info:FormInfo, callback: AsyncCallback&lt;void&gt;):void
1143
1144从数据库中删除图库卡片信息,使用callback方式返回结果。
1145
1146**系统接口**:此接口为系统接口。
1147
1148**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
1149
1150**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
1151
1152**参数:**
1153
1154| 参数名   | 类型                     | 必填 | 说明                      |
1155| -------- | ------------------------ | ---- | ------------------------- |
1156| info  | [FormInfo](#forminfo11)        | 是   |  图库卡片信息,包括图库卡片的id和卡片绑定的图片的uri。              |
1157| callback |  AsyncCallback&lt;void&gt; | 是   | callback返回void。 |
1158
1159**错误码:**
1160
1161接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
1162
1163| 错误码ID | 错误信息 |
1164| -------- | ---------------------------------------- |
1165| 201   | Permission verification failed, usually the result returned by VerifyAccessToken.         |
1166| 202   | Permission verification failed, application which is not a system application uses system API.         |
1167| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1168| 14000011       | System inner fail.         |
1169
1170**示例:**
1171
1172```ts
1173import { BusinessError } from '@kit.BasicServicesKit';
1174
1175async function example() {
1176  console.info('removeFormInfoDemo');
1177  let info: photoAccessHelper.FormInfo = {
1178    //formId是一个由纯数字组成的字符串,移除卡片的时候uri填空即可。
1179    formId: "20230116123",
1180    uri: "",
1181  }
1182
1183  phAccessHelper.removeFormInfo(info, async (err: BusinessError) => {
1184    if (err == undefined) {
1185      console.info('removeFormInfo success');
1186    } else {
1187      console.error(`removeFormInfo fail with error: ${err.code}, ${err.message}`);
1188    }
1189  });
1190}
1191```
1192
1193### removeFormInfo<sup>11+</sup>
1194
1195removeFormInfo(info:FormInfo):Promise&lt;void&gt;
1196
1197从数据库中删除图库卡片信息,使用Promise方式返回结果。
1198
1199**系统接口**:此接口为系统接口。
1200
1201**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
1202
1203**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
1204
1205**参数:**
1206
1207| 参数名   | 类型                     | 必填 | 说明                      |
1208| -------- | ------------------------ | ---- | ------------------------- |
1209| info  | [FormInfo](#forminfo11)        | 是   |  图库卡片信息,包括图库卡片的id和卡片绑定的图片的uri。              |
1210
1211**返回值:**
1212
1213| 类型                                    | 说明              |
1214| --------------------------------------- | ----------------- |
1215| Promise&lt;void&gt;| Promise对象,返回void。 |
1216
1217**错误码:**
1218
1219接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
1220
1221| 错误码ID | 错误信息 |
1222| -------- | ---------------------------------------- |
1223| 201   | Permission verification failed, usually the result returned by VerifyAccessToken.         |
1224| 202   | Permission verification failed, application which is not a system application uses system API.         |
1225| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1226| 14000011       | System inner fail.         |
1227
1228**示例:**
1229
1230```ts
1231import { BusinessError } from '@kit.BasicServicesKit';
1232
1233async function example() {
1234  console.info('removeFormInfoDemo');
1235  let info: photoAccessHelper.FormInfo = {
1236    //formId是一个由纯数字组成的字符串,移除卡片的时候uri填空即可。
1237    formId: "20230116123",
1238    uri: "",
1239  }
1240
1241  phAccessHelper.removeFormInfo(info).then(() => {
1242    console.info('removeFormInfo successfully');
1243  }).catch((err: BusinessError) => {
1244    console.error(`removeFormInfo failed with error: ${err.code}, ${err.message}`);
1245  });
1246}
1247```
1248
1249### createAssetsForApp<sup>12+</sup>
1250
1251createAssetsForApp(bundleName: string, appName: string, appId: string, photoCreationConfigs: Array&lt;PhotoCreationConfig&gt;): Promise&lt;Array&lt;string&gt;&gt;
1252
1253调用接口代替应用创建媒体库uri列表。Uri已对appId对应的应用授权,支持应用使用uri写入图片/视频。
1254
1255**系统接口**:此接口为系统接口。
1256
1257**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
1258
1259**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
1260
1261**参数:**
1262
1263| 参数名   | 类型                                                                   | 必填 | 说明                      |
1264| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
1265| bundleName | string | 是 | 需保存图片/视频文件的应用bundle name。 |
1266| appName | string | 是 | 需保存图片/视频文件的应用app name。 |
1267| appId | string | 是 | 需保存图片/视频文件的应用app id。 |
1268| photoCreationConfigs | Array&lt;[PhotoCreationConfig](./js-apis-photoAccessHelper.md#photocreationconfig12)&gt; | 是 | 保存图片/视频到媒体库的配置。 |
1269
1270**返回值:**
1271
1272| 类型                                    | 说明              |
1273| --------------------------------------- | ----------------- |
1274| Promise&lt;Array&lt;string&gt;&gt; | Promise对象,返回给接口调用方的的媒体库文件uri列表。Uri已对appId对应的应用授权,支持应用写入数据。如果生成uri异常,则返回批量创建错误码。<br>返回-3006表不允许出现非法字符;返回-2004表示图片类型和后缀不符;返回-203表示文件操作异常。 |
1275
1276**错误码:**
1277
1278接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
1279
1280| 错误码ID | 错误信息 |
1281| -------- | ---------------------------------------- |
1282| 201 |  Permission denied.         |
1283| 202 |  Called by non-system application.         |
1284| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types; 3. Parameter verification failed. |
1285| 14000011       | Internal system error.         |
1286
1287**示例:**
1288
1289```ts
1290async function example() {
1291  console.info('createAssetsForAppDemo.');
1292
1293  try {
1294    let bundleName: string = 'testBundleName';
1295    let appName: string = 'testAppName';
1296    let appId: string = 'testAppId';
1297    let photoCreationConfigs: Array<photoAccessHelper.PhotoCreationConfig> = [
1298      {
1299        title: 'test',
1300        fileNameExtension: 'jpg',
1301        photoType: photoAccessHelper.PhotoType.IMAGE,
1302        subtype: photoAccessHelper.PhotoSubtype.DEFAULT,
1303      }
1304    ];
1305    let desFileUris: Array<string> = await phAccessHelper.createAssetsForApp(bundleName, appName, appId, photoCreationConfigs);
1306    console.info('createAssetsForApp success, data is ' + desFileUris);
1307  } catch (err) {
1308    console.error(`createAssetsForApp failed with error: ${err.code}, ${err.message}`);
1309  }
1310}
1311```
1312
1313### grantPhotoUriPermission<sup>15+</sup>
1314
1315grantPhotoUriPermission(tokenId: number, uri: string, photoPermissionType: PhotoPermissionType, hideSensitiveType: HideSensitiveType): Promise&lt;number&gt;
1316
1317给应用授予uri的访问权限,使用Promise方式返回结果。
1318
1319**系统接口**:此接口为系统接口。
1320
1321**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
1322
1323**需要权限:** ohos.permission.WRITE_IMAGEVIDEO
1324
1325**参数:**
1326
1327| 参数名   | 类型                                                                   | 必填 | 说明                      |
1328| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
1329| tokenId | number | 是 | 应用标识,将访问权限授予给tokenId标识的应用。 |
1330| uri | string | 是 | 媒体资源的uri,uri表示的资源的访问权限将授予给应用。|
1331| photoPermissionType | [PhotoPermissionType](#photopermissiontype12) | 是 | 权限类型,将photoPermissionType表示的权限授予给应用。权限的覆盖规则参考枚举类。|
1332| hideSensitiveType | [HideSensitiveType](#hidesensitivetype12) | 是 | 脱敏类型,预留参数,目前可传枚举类中任一值。|
1333
1334**返回值:**
1335
1336| 类型                                    | 说明              |
1337| --------------------------------------- | ----------------- |
1338| Promise&lt;number&gt; | Promise对象,0:授权成功。 1:已有权限。-1:授权失败。|
1339
1340**错误码:**
1341
1342接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
1343
1344| 错误码ID | 错误信息 |
1345| -------- | ---------------------------------------- |
1346| 201 |  Permission denied.         |
1347| 202 |  Called by non-system application.         |
1348| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types; 3. Parameter verification failed. |
1349| 14000011       | Internal system error.         |
1350
1351**示例:**
1352
1353```ts
1354async function example() {
1355  console.info('grantPhotoUriPermissionDemo');
1356
1357  try {
1358    let tokenId = 502334412;
1359    let result = await phAccessHelper.grantPhotoUriPermission(tokenId,
1360        'file://media/Photo/1/IMG_datetime_0001/displayName.jpg',
1361        photoAccessHelper.PhotoPermissionType.TEMPORARY_READ_IMAGEVIDEO,
1362        photoAccessHelper.HideSensitiveType.HIDE_LOCATION_AND_SHOTING_PARM);
1363
1364    console.info('grantPhotoUriPermission success, result=' + result);
1365  } catch (err) {
1366    console.error('grantPhotoUriPermission failed, error=' + err);
1367  }
1368}
1369```
1370
1371### grantPhotoUrisPermission<sup>15+</sup>
1372
1373grantPhotoUrisPermission(tokenId: number, uriList: Array&lt;string&gt;, photoPermissionType: PhotoPermissionType, hideSensitiveType: HideSensitiveType): Promise&lt;number&gt;
1374
1375给应用授予uri列表的访问权限,使用Promise方式返回结果。
1376
1377**系统接口**:此接口为系统接口。
1378
1379**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
1380
1381**需要权限:** ohos.permission.WRITE_IMAGEVIDEO
1382
1383**参数:**
1384
1385| 参数名   | 类型                                                                   | 必填 | 说明                      |
1386| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
1387| tokenId | number | 是 | 应用标识,将访问权限授予给tokenId标识的应用。 |
1388| uriList | Array&lt;string&gt; | 是 | 媒体资源的uri列表,uri列表中的资源的访问权限将授予给应用。uri列表最多容纳 1000 条uri。|
1389| photoPermissionType | [PhotoPermissionType](#photopermissiontype12) | 是 | 权限类型,将photoPermissionType表示的权限授予给应用。权限的覆盖规则参考枚举类。|
1390| hideSensitiveType | [HideSensitiveType](#hidesensitivetype12) | 是 | 脱敏类型,预留参数,目前可传枚举类中任一值。|
1391
1392**返回值:**
1393
1394| 类型                                    | 说明              |
1395| --------------------------------------- | ----------------- |
1396| Promise&lt;number&gt; | Promise对象,0: 授权成功。 -1:授权失败。|
1397
1398**错误码:**
1399
1400接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
1401
1402| 错误码ID | 错误信息 |
1403| -------- | ---------------------------------------- |
1404| 201 |  Permission denied.         |
1405| 202 |  Called by non-system application.         |
1406| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types; 3. Parameter verification failed. |
1407| 14000011       | Internal system error.         |
1408
1409**示例:**
1410
1411```ts
1412async function example() {
1413  console.info('grantPhotoUrisPermissionDemo');
1414
1415  try {
1416    // 媒体资源的uri列表。
1417    let uris: Array<string> = [
1418      'file://media/Photo/11/IMG_datetime_0001/displayName1.jpg',
1419      'file://media/Photo/22/IMG_datetime_0002/displayName2.jpg'];
1420    let tokenId = 502334412;
1421    let result = await phAccessHelper.grantPhotoUrisPermission(tokenId, uris,
1422        photoAccessHelper.PhotoPermissionType.TEMPORARY_READ_IMAGEVIDEO,
1423        photoAccessHelper.HideSensitiveType.HIDE_LOCATION_AND_SHOTING_PARM);
1424
1425    console.info('grantPhotoUrisPermission success, result=' + result);
1426  } catch (err) {
1427    console.error('grantPhotoUrisPermission failed, error=' + err);
1428  }
1429}
1430```
1431
1432### cancelPhotoUriPermission<sup>15+</sup>
1433
1434cancelPhotoUriPermission(tokenId: number, uri: string, photoPermissionType: PhotoPermissionType): Promise&lt;number&gt;
1435
1436取消应用对uri的访问权限,使用Promise方式返回结果。
1437
1438**系统接口**:此接口为系统接口。
1439
1440**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
1441
1442**需要权限:** ohos.permission.WRITE_IMAGEVIDEO
1443
1444**参数:**
1445
1446| 参数名   | 类型                                                                   | 必填 | 说明                      |
1447| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
1448| tokenId | number | 是 | 应用标识,将取消tokenId标识应用对媒体资源的访问权限。 |
1449| uri | string | 是 | 媒体资源的uri,取消应用对uri表示的资源的访问权限。|
1450| photoPermissionType | [PhotoPermissionType](#photopermissiontype12) | 是 | 权限类型,取消应用对媒体资源的访问权限为photoPermissionType。|
1451
1452**返回值:**
1453
1454| 类型                                    | 说明              |
1455| --------------------------------------- | ----------------- |
1456| Promise&lt;number&gt; | Promise对象,0:取消成功。-1:取消失败。|
1457
1458**错误码:**
1459
1460接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
1461
1462| 错误码ID | 错误信息 |
1463| -------- | ---------------------------------------- |
1464| 201 |  Permission denied.         |
1465| 202 |  Called by non-system application.         |
1466| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types; 3. Parameter verification failed. |
1467| 14000011       | Internal system error.         |
1468
1469**示例:**
1470
1471```ts
1472async function example() {
1473  console.info('cancelPhotoUriPermissionDemo');
1474
1475  try {
1476    let tokenId = 502334412;
1477    let result = await phAccessHelper.cancelPhotoUriPermission(tokenId,
1478        'file://media/Photo/11/IMG_datetime_0001/displayName.jpg',
1479        photoAccessHelper.PhotoPermissionType.TEMPORARY_READ_IMAGEVIDEO);
1480
1481    console.info('cancelPhotoUriPermission success, result=' + result);
1482  } catch (err) {
1483    console.error('cancelPhotoUriPermission failed, error=' + err);
1484  }
1485}
1486```
1487
1488### startAssetAnalysis<sup>18+</sup>
1489
1490startAssetAnalysis(type: AnalysisType, assetUris?: Array&lt;string&gt;): Promise&lt;number&gt;
1491
1492启动资产分析服务。
1493
1494**系统接口**:此接口为系统接口。
1495
1496**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
1497
1498**需要权限:** ohos.permission.WRITE_IMAGEVIDEO
1499
1500**参数:**
1501
1502| 参数名    | 类型                | 必填 | 说明                                                         |
1503| --------- | ------------------- | ---- | ------------------------------------------------------------ |
1504| type      | number              | 是   | 需要启动的智慧分析类型。                                     |
1505| assetUris | Array&lt;string&gt; | 否   | 资产uri的数组。<br>- 填写:仅分析指定资产。<br>- 不填:全量分析。 |
1506
1507**返回值:**
1508
1509| 类型                  | 说明                        |
1510| --------------------- | --------------------------- |
1511| Promise&lt;number&gt; | Promise对象。服务的任务id。 |
1512
1513**错误码:**
1514
1515以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1516
1517| 错误码ID | 错误信息                                                     |
1518| -------- | ------------------------------------------------------------ |
1519| 201      | Permission denied.                                           |
1520| 202      | Called by non-system application.                            |
1521| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types; 3. Parameter verification failed. |
1522
1523**示例:**
1524
1525```ts
1526import { common } from '@kit.AbilityKit';
1527
1528// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
1529let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
1530
1531async function example() {
1532  console.info('startAssetAnalysisDemo');
1533  try {
1534    let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
1535    let uris = ["file://media/Photo/14/IMG_1729066473_013/IMG_20241016_122253.jpg",
1536                "file://media/Photo/68/IMG_1729033213_018/IMG_20241016_100082.jpg"];
1537    let taskId = await phAccessHelper.startAssetAnalysis(photoAccessHelper.AnalysisType.ANALYSIS_SEARCH_INDEX,
1538        uris);
1539    console.info('startAssetAnalysis success, taskId=' + taskId);
1540  } catch (err) {
1541    console.error('startAssetAnalysis failed, error=' + err);
1542  }
1543}
1544```
1545
1546### createAssetsForAppWithMode<sup>12+</sup>
1547
1548createAssetsForAppWithMode(boundleName: string, appName: string, appId: string, tokenId: number, authorizationMode: AuthorizationMode, photoCreationConfigs:Array\<PhotoCreationConfig>): Promise\<Array\<string>>
1549
1550提供给应用保存短时授权,使用Promise方式返回结果。
1551
1552**系统接口**:此接口为系统接口。
1553
1554**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
1555
1556**需要权限:** ohos.permission.WRITE_IMAGEVIDEO
1557
1558**参数:**
1559
1560| 参数名   | 类型                                                                   | 必填 | 说明                      |
1561| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
1562| boundleName| string | 是 | 需要保存图片/视频文件的应用boundleName。 |
1563| appName| string | 是 | 需要保存图片/视频文件的应用appName。|
1564| appId| string | 是 | 需要保存图片/视频文件的应用app id。 |
1565| tokenId| number| 是 | 需要短时授权应用的唯一标识。 |
1566| authorizationMode| [AuthorizationMode](#authorizationmode12)| 是 | 授权模式。授予应用短期内再次保存无需重复弹框确认。 |
1567| PhotoCreationConfig| Array\<[PhotoCreationConfig](js-apis-photoAccessHelper.md#photocreationconfig12)> | 是 | 保存图片/视频到媒体库的配置。|
1568
1569**返回值:**
1570
1571| 类型                                    | 说明              |
1572| --------------------------------------- | ----------------- |
1573| Promise\<Array\<string>> | Promise对象,返回给接口调用方的媒体库文件uri列表。Uri已对appId对应的应用授权,支持应用写入数据。如果生成uri异常,则返回批量创建错误码。<br>返回-3006表不允许出现非法字符;返回-2004表示图片类型和后缀不符;返回-203表示文件操作异常。|
1574
1575**错误码:**
1576
1577接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
1578
1579| 错误码ID | 错误信息 |
1580| -------- | ---------------------------------------- |
1581| 201 |  Permission denied.         |
1582| 202 |  Called by non-system application.         |
1583| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types; 3. Parameter verification failed. |
1584| 14000011       | Internal system error.         |
1585
1586**示例:**
1587
1588```ts
1589async function example() {
1590  console.info('createAssetsForAppWithModeDemo.');
1591
1592  try {
1593    let photoCreationConfigs: Array<photoAccessHelper.PhotoCreationConfig> = [
1594      {
1595        title: '123456',
1596        fileNameExtension: 'jpg',
1597        photoType: photoAccessHelper.PhotoType.IMAGE,
1598        subtype: photoAccessHelper.PhotoSubtype.DEFAULT,
1599      }
1600    ];
1601    let bundleName: string = 'testBundleName';
1602    let appName: string = 'testAppName';
1603    let appId: string = 'testAppId';
1604    let tokenId: number = 537197950;
1605    let authorizationMode: photoAccessHelper.AuthorizationMode = photoAccessHelper.AuthorizationMode.SHORT_TIME_AUTHORIZATION;
1606    let result: Array<string> = await phAccessHelper.createAssetsForAppWithMode(bundleName, appName, appId, tokenId, authorizationMode, photoCreationConfigs);
1607    console.info(`result: ${JSON.stringify(result)}`);
1608    console.info('Photo createAssetsForAppWithMode success.');
1609  } catch (err) {
1610    console.error(`createAssetsForAppWithMode failed with error: ${err.code}, ${err.message}`);
1611  }
1612}
1613```
1614
1615### getKeyFrameThumbnail<sup>18+</sup>
1616
1617getKeyFrameThumbnail(beginFrameTimeMs: number, type: ThumbnailType): Promise<image.PixelMap>
1618
1619获取视频中关键视频帧位置的指定类型缩略图,使用promise方式返回异步结果。
1620
1621**系统接口**:此接口为系统接口。
1622
1623**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
1624
1625**需要权限**:ohos.permission.READ_IMAGEVIDEO
1626
1627**参数:**
1628
1629| 参数名  | 类型             | 必填   | 说明    |
1630| ---- | -------------- | ---- | ----- |
1631| beginFrameTimeMs | number | 是    | 获取视频帧的时间位置,单位ms,0:封面帧。 |
1632| type | [ThumbnailType](#thumbnailtype13)| 是    | 缩略图类型。 |
1633
1634**返回值:**
1635
1636| 类型                            | 说明                    |
1637| ----------------------------- | --------------------- |
1638| Promise&lt;[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)&gt; | Promise对象,返回缩略图的PixelMap。若获取不到,默认返回封面帧 |
1639
1640**错误码:**
1641
1642接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
1643
1644| 错误码ID | 错误信息 |
1645| -------- | ---------------------------------------- |
1646| 201   | Permission denied.       |
1647| 202   | Called by non-system application.       |
1648| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1649| 14000011   | Internal system error.
1650
1651**示例:**
1652
1653```ts
1654import { common }  from '@kit.AbilityKit';
1655import { photoAccessHelper } from '@kit.MediaLibraryKit';
1656import { dataSharePredicates } from '@kit.ArkData';
1657import { image } from '@kit.ImageKit';
1658
1659// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
1660let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
1661
1662async function example() {
1663  try{
1664    console.info('getKeyFrameThumbnail demo');
1665    let phAccessHelper:photoAccessHelper.PhotoAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
1666    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1667    predicates.equalTo(photoAccessHelper.PhotoKeys.PHOTO_TYPE, photoAccessHelper.PhotoType.VIDEO);
1668    let fetchOption: photoAccessHelper.FetchOptions = {
1669      fetchColumns: [],
1670      predicates: predicates
1671    };
1672    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
1673    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getLastObject();
1674    let pixelMap: image.PixelMap = await asset.getKeyFrameThumbnail(0, photoAccessHelper.ThumbnailType.LCD);
1675    console.info('getKeyFrameThumbnail success');
1676  } catch (error) {
1677    console.error('getKeyFrameThumbnail failed, error: ' + JSON.stringify(error));
1678  }
1679}
1680```
1681
1682### saveGalleryFormInfo<sup>18+</sup>
1683
1684saveGalleryFormInfo(info:GalleryFormInfo):Promise&lt;void&gt;
1685
1686将图库卡片相关信息保存到数据库中,使用Promise方式返回结果。
1687
1688**系统接口**:此接口为系统接口。
1689
1690**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
1691
1692**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
1693
1694**参数:**
1695
1696| 参数名   | 类型                     | 必填 | 说明                      |
1697| -------- | ------------------------ | ---- | ------------------------- |
1698| info  | [GalleryFormInfo](#galleryforminfo18)        | 是   | 图库卡片信息,包括图库卡片的id、卡片绑定的图片或相册的uri集合。              |
1699
1700**返回值:**
1701
1702| 类型                                    | 说明              |
1703| --------------------------------------- | ----------------- |
1704| Promise&lt;void&gt;| Promise对象,返回void。 |
1705
1706**错误码:**
1707
1708以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
1709
1710| 错误码ID | 错误信息 |
1711| -------- | ---------------------------------------- |
1712| 201   | Permission verification failed, usually the result returned by VerifyAccessToken.         |
1713| 202   | Permission verification failed, application which is not a system application uses system API.         |
1714| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1715| 14000011       | System inner fail.         |
1716
1717**示例:**
1718
1719```ts
1720import { dataSharePredicates } from '@kit.ArkData';
1721import { BusinessError } from '@kit.BasicServicesKit';
1722import {photoAccessHelper} from '@kit.MediaLibraryKit';
1723import { common } from '@kit.AbilityKit';
1724
1725// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
1726let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
1727let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
1728
1729async function example() {
1730  console.info('saveGalleryFormInfoDemo');
1731  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1732  let fetchOptions: photoAccessHelper.FetchOptions = {
1733    fetchColumns: [],
1734    predicates: predicates
1735  };
1736  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1737  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1738  let uriList: Array<string> = [
1739    photoAsset.uri,
1740  ];
1741  let info: photoAccessHelper.GalleryFormInfo = {
1742    // formId是一个由纯数字组成的字符串,assetUris为图库中存在的图片或者相册的uri信息集合。
1743    formId: "20230116123",
1744    assetUris: uriList,
1745  }
1746
1747  phAccessHelper.saveGalleryFormInfo(info).then(() => {
1748    console.info('saveGalleryFormInfo successfully');
1749  }).catch((err: BusinessError) => {
1750    console.error(`saveGalleryFormInfo failed with error: ${err.code}, ${err.message}`);
1751  });
1752}
1753```
1754
1755### updateGalleryFormInfo<sup>18+</sup>
1756
1757updateGalleryFormInfo(info:GalleryFormInfo):Promise&lt;void&gt;
1758
1759更新既存的图库卡片的相关信息,并保存到数据库中,使用Promise方式返回结果。
1760
1761**系统接口**:此接口为系统接口。
1762
1763**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
1764
1765**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
1766
1767**参数:**
1768
1769| 参数名   | 类型                     | 必填 | 说明                      |
1770| -------- | ------------------------ | ---- | ------------------------- |
1771| info  | [GalleryFormInfo](#galleryforminfo18)        | 是   | 图库卡片信息,包括图库卡片的id、卡片绑定的图片或相册的uri集合。              |
1772
1773**返回值:**
1774
1775| 类型                                    | 说明              |
1776| --------------------------------------- | ----------------- |
1777| Promise&lt;void&gt;| Promise对象,返回void。 |
1778
1779**错误码:**
1780
1781以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
1782
1783| 错误码ID | 错误信息 |
1784| -------- | ---------------------------------------- |
1785| 201   | Permission verification failed, usually the result returned by VerifyAccessToken.         |
1786| 202   | Permission verification failed, application which is not a system application uses system API.         |
1787| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1788| 14000011       | System inner fail.         |
1789
1790**示例:**
1791
1792```ts
1793import { dataSharePredicates } from '@kit.ArkData';
1794import { BusinessError } from '@kit.BasicServicesKit';
1795import {photoAccessHelper} from '@kit.MediaLibraryKit';
1796import { common } from '@kit.AbilityKit';
1797
1798// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
1799let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
1800let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
1801
1802async function example() {
1803  console.info('updateGalleryFormInfoDemo');
1804  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
1805  let fetchOptions: photoAccessHelper.FetchOptions = {
1806    fetchColumns: [],
1807    predicates: predicates
1808  };
1809  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
1810  let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
1811  let photoAssetLast: photoAccessHelper.PhotoAsset = await fetchResult.getLastObject();
1812  let uriList: Array<string> = [
1813    photoAsset.uri,
1814    photoAssetLast.uri
1815  ];
1816  let info: photoAccessHelper.GalleryFormInfo = {
1817    // formId是一个由纯数字组成的字符串,assetUris为图库中存在的图片或者相册的uri信息集合。
1818    formId: "20230116123",
1819    assetUris: uriList,
1820  }
1821
1822  phAccessHelper.updateGalleryFormInfo(info).then(() => {
1823    console.info('updateGalleryFormInfo successfully');
1824  }).catch((err: BusinessError) => {
1825    console.error(`updateGalleryFormInfo failed with error: ${err.code}, ${err.message}`);
1826  });
1827}
1828```
1829
1830### removeGalleryFormInfo<sup>18+</sup>
1831
1832removeGalleryFormInfo(info:GalleryFormInfo):Promise&lt;void&gt;
1833
1834从数据库中删除图库卡片信息,使用Promise方式返回结果。
1835
1836**系统接口**:此接口为系统接口。
1837
1838**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
1839
1840**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
1841
1842**参数:**
1843
1844| 参数名   | 类型                     | 必填 | 说明                      |
1845| -------- | ------------------------ | ---- | ------------------------- |
1846| info  | [GalleryFormInfo](#galleryforminfo18)        | 是   | 图库卡片信息,包括图库卡片的id、卡片绑定的图片或相册的uri集合。              |
1847
1848**返回值:**
1849
1850| 类型                                    | 说明              |
1851| --------------------------------------- | ----------------- |
1852| Promise&lt;void&gt;| Promise对象,返回void。 |
1853
1854**错误码:**
1855
1856以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
1857
1858| 错误码ID | 错误信息 |
1859| -------- | ---------------------------------------- |
1860| 201   | Permission verification failed, usually the result returned by VerifyAccessToken.         |
1861| 202   | Permission verification failed, application which is not a system application uses system API.         |
1862| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1863| 14000011       | System inner fail.         |
1864
1865**示例:**
1866
1867```ts
1868import { BusinessError } from '@kit.BasicServicesKit';
1869import {photoAccessHelper} from '@kit.MediaLibraryKit';
1870import { common } from '@kit.AbilityKit';
1871
1872// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
1873let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
1874let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
1875
1876async function example() {
1877  console.info('removeGalleryFormInfoDemo');
1878  let info: photoAccessHelper.GalleryFormInfo = {
1879    // formId是一个由纯数字组成的字符串,移除卡片时assertUris不填。
1880    formId: "20230116123"
1881  }
1882
1883  phAccessHelper.removeGalleryFormInfo(info).then(() => {
1884    console.info('removeGalleryFormInfo successfully');
1885  }).catch((err: BusinessError) => {
1886    console.error(`removeGalleryFormInfo failed with error: ${err.code}, ${err.message}`);
1887  });
1888}
1889```
1890
1891
1892### getAlbumsByIds<sup>18+</sup>
1893
1894getAlbumsByIds(albumIds: Array&lt;number&gt;): Promise&lt;Map&lt;number, Album&gt;&gt;
1895
1896通过相册id查询相册信息。使用Promise异步回调。
1897
1898**系统接口**:此接口为系统接口。
1899
1900**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
1901
1902**需要权限:** ohos.permission.READ_IMAGEVIDEO
1903
1904**参数:**
1905
1906| 参数名    | 类型                | 必填 | 说明                                                         |
1907| --------- | ------------------- | ---- | ------------------------------------------------------------ |
1908| albumIds  | Array&lt;number&gt;              | 是   | 相册id列表。                                     |
1909
1910**返回值:**
1911
1912| 类型                  | 说明                        |
1913| --------------------- | --------------------------- |
1914| Promise&lt;Map&lt;number, Album&gt;&gt; | Promise对象。返回相册信息map对象。 |
1915
1916**错误码:**
1917
1918以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
1919
1920| 错误码ID | 错误信息                                                     |
1921| -------- | ------------------------------------------------------------ |
1922| 201      | Permission denied.                                           |
1923| 202      | Called by non-system application.                            |
1924| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types; 3. Parameter verification failed. |
1925| 14000011       | Internal system error.         |
1926
1927**示例:**
1928
1929```ts
1930async function example() {
1931  console.info('startGetAlbumsByIdsDemo');
1932
1933  try {
1934    // 获取需要保存到媒体库的位于应用沙箱的图片/视频uri。
1935    let albumIds: Array<number> = [
1936      12 // 实际场景请使用albumId
1937    ];
1938    let map: Map<number, photoAccessHelper.Album> = await phAccessHelper.getAlbumsByIds(albumIds);
1939    console.info('getAlbumsByIds success, size is ' + map.size);
1940  } catch (err) {
1941    console.error('getAlbumsByIds failed, errCode is ' + err.code + ', errMsg is ' + err.message);
1942  }
1943}
1944```
1945
1946### createAssetsForAppWithAlbum<sup>18+</sup>
1947
1948createAssetsForAppWithAlbum(source: PhotoCreationSource, albumUri: string, isAuthorized: boolean, photoCreationConfigs: Array&lt;PhotoCreationConfig&gt;): Promise&lt;Array&lt;string&gt;&gt;
1949
1950为应用自己或者其他应用创建资产到指定来源或者用户相册。使用Promise异步回调。
1951
1952**系统接口**:此接口为系统接口。
1953
1954**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
1955
1956**需要权限:** ohos.permission.WRITE_IMAGEVIDEO
1957
1958**参数:**
1959
1960| 参数名    | 类型                | 必填 | 说明                                                         |
1961| --------- | ------------------- | ---- | ------------------------------------------------------------ |
1962| source  | [PhotoCreationSource](#photocreationsource18)         | 是   | 代替应用创建资产传入的应用信息。                                     |
1963| albumUri  | string             | 是   | 相册uri。                                     |
1964| isAuthorized  |  boolean              | 是   | 是否授权其他应用。true表示授权,false表示不授权。                                     |
1965| PhotoCreationConfigs| Array\<[PhotoCreationConfig](js-apis-photoAccessHelper.md#photocreationconfig12)> | 是 | 保存图片/视频到媒体库的配置。|
1966
1967**返回值:**
1968
1969| 类型                  | 说明                        |
1970| --------------------- | --------------------------- |
1971| Promise&lt;Array&lt;string&gt;&gt; | Promise对象,返回接口调用方的媒体库文件uri列表。<br>uri已对appId对应的应用授权,支持应用写入数据。如果生成uri异常,则返回批量创建错误码。<br>返回-3006表示不允许出现非法字符;返回-2004表示图片类型和后缀不符;返回-203表示文件操作异常。 |
1972
1973**错误码:**
1974
1975以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
1976
1977| 错误码ID | 错误信息                                                     |
1978| -------- | ------------------------------------------------------------ |
1979| 201      | Permission denied.                                           |
1980| 202      | Called by non-system application.                            |
1981| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types; 3. Parameter verification failed. |
1982| 14000011       | Internal system error.         |
1983
1984**示例:**
1985
1986```ts
1987async function example() {
1988  console.info('createAssetsForAppWithAlbumDemo.');
1989
1990  try {
1991    let source: photoAccessHelper.PhotoCreationSource = {
1992      bundleName: 'testBundleName',
1993      appName: 'testAppName',
1994      appId: 'testAppId',
1995      tokenId: 537197950,
1996    }
1997    let albumUri: string = 'file://media/PhotoAlbum/10';
1998    let isAuthorized: boolean = true;
1999    let photoCreationConfigs: Array<photoAccessHelper.PhotoCreationConfig> = [
2000      {
2001        title: 'test',
2002        fileNameExtension: 'jpg',
2003        photoType: photoAccessHelper.PhotoType.IMAGE,
2004        subtype: photoAccessHelper.PhotoSubtype.DEFAULT,
2005      }
2006    ];
2007    let desFileUris: Array<string> = await phAccessHelper.createAssetsForAppWithAlbum(source, albumUri, isAuthorized, photoCreationConfigs);
2008    console.info('createAssetsForAppWithAlbum success, data is ' + desFileUris);
2009  } catch (err) {
2010    console.error(`createAssetsForAppWithAlbum failed with error: ${err.code}, ${err.message}`);
2011  }
2012}
2013```
2014
2015## PhotoAsset
2016
2017提供封装文件属性的方法。
2018
2019### open<sup>(deprecated)</sup>
2020
2021open(mode: string, callback: AsyncCallback&lt;number&gt;): void
2022
2023打开当前文件,使用callback方式返回异步结果。
2024
2025> **说明:**
2026>
2027> 从API version 10开始支持,从API version 11开始废弃。出于安全考量,不再提供获取正式媒体文件句柄的接口。
2028
2029**注意**:当前此(写)操作是互斥的操作,返回的文件描述符在使用完毕后需要调用close进行释放。
2030
2031**系统接口**:此接口为系统接口。
2032
2033**需要权限**:ohos.permission.READ_IMAGEVIDEOohos.permission.WRITE_IMAGEVIDEO
2034
2035**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
2036
2037**参数:**
2038
2039| 参数名      | 类型                          | 必填   | 说明                                  |
2040| -------- | --------------------------- | ---- | ----------------------------------- |
2041| mode     | string                      | 是    | 打开文件方式,分别为:'r'(只读), 'w'(只写), 'rw'(读写)。 |
2042| callback | AsyncCallback&lt;number&gt; | 是    | callback返回文件描述符。                            |
2043
2044**错误码:**
2045
2046接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
2047
2048| 错误码ID | 错误信息 |
2049| -------- | ---------------------------------------- |
2050| 202     |  Called by non-system application.         |
2051| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2052| 13900012     | Permission denied.         |
2053| 13900020     | Invalid argument.         |
2054| 14000011       | System inner fail.         |
2055
2056**示例:**
2057
2058```ts
2059async function example() {
2060  console.info('Open demo');
2061  let testFileName: string = 'testFile' + Date.now() + '.jpg';
2062  let photoAsset: photoAccessHelper.PhotoAsset = await phAccessHelper.createAsset(testFileName);
2063  photoAsset.open('rw', (err, fd) => {
2064    if (fd !== undefined) {
2065      console.info('File fd' + fd);
2066      photoAsset.close(fd);
2067    } else {
2068      console.error(`Open file err: ${err.code}, ${err.message}`);
2069    }
2070  });
2071}
2072```
2073
2074### open<sup>(deprecated)</sup>
2075
2076open(mode: string): Promise&lt;number&gt;
2077
2078打开当前文件,使用promise方式返回异步结果。
2079
2080> **说明:**
2081>
2082> 从API version 10开始支持,从API version 11开始废弃。出于安全考量,不再提供获取正式媒体文件句柄的接口。
2083
2084**注意**:当前此(写)操作是互斥的操作,返回的文件描述符在使用完毕后需要调用close进行释放。
2085
2086**系统接口**:此接口为系统接口。
2087
2088**需要权限**:ohos.permission.READ_IMAGEVIDEOohos.permission.WRITE_IMAGEVIDEO
2089
2090**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
2091
2092**参数:**
2093
2094| 参数名  | 类型     | 必填   | 说明                                  |
2095| ---- | ------ | ---- | ----------------------------------- |
2096| mode | string | 是    | 打开文件方式,分别为:'r'(只读), 'w'(只写), 'rw'(读写)。 |
2097
2098**返回值:**
2099
2100| 类型                    | 说明            |
2101| --------------------- | ------------- |
2102| Promise&lt;number&gt; | Promise对象,返回文件描述符。 |
2103
2104**错误码:**
2105
2106接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
2107
2108| 错误码ID | 错误信息 |
2109| -------- | ---------------------------------------- |
2110| 202     |  Called by non-system application.         |
2111| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2112| 13900012     | Permission denied.         |
2113| 13900020     | Invalid argument.         |
2114| 14000011       | System inner fail.         |
2115
2116**示例:**
2117
2118```ts
2119async function example() {
2120  console.info('Open demo');
2121  try {
2122    let testFileName: string = 'testFile' + Date.now() + '.jpg';
2123    let photoAsset: photoAccessHelper.PhotoAsset = await phAccessHelper.createAsset(testFileName);
2124    let fd: number = await photoAsset.open('rw');
2125    if (fd !== undefined) {
2126      console.info('File fd' + fd);
2127      photoAsset.close(fd);
2128    } else {
2129      console.error('Open file fail');
2130    }
2131  } catch (err) {
2132    console.error(`Open demo err: ${err.code}, ${err.message}`);
2133  }
2134}
2135```
2136
2137### setFavorite<sup>(deprecated)</sup>
2138
2139setFavorite(favoriteState: boolean, callback: AsyncCallback&lt;void&gt;): void
2140
2141将文件设置为收藏文件,使用callback方式返回异步结果。
2142
2143> **说明:**
2144>
2145> 从API version 10开始支持,从API version 11开始废弃。建议使用[MediaAssetChangeRequest.setFavorite](#setfavorite11)替代。
2146
2147**系统接口**:此接口为系统接口。
2148
2149**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
2150
2151**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
2152
2153**参数:**
2154
2155| 参数名        | 类型                        | 必填   | 说明                                 |
2156| ---------- | ------------------------- | ---- | ---------------------------------- |
2157| favoriteState | boolean                   | 是    | 是否设置为收藏文件, true:设置为收藏文件,false:取消收藏。 |
2158| callback   | AsyncCallback&lt;void&gt; | 是    | callback返回void。                              |
2159
2160**错误码:**
2161
2162接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
2163
2164| 错误码ID | 错误信息 |
2165| -------- | ---------------------------------------- |
2166| 202        |  Called by non-system application.         |
2167| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2168| 13900012     | Permission denied.         |
2169| 13900020     | Invalid argument.         |
2170| 14000011       | System inner fail.         |
2171
2172**示例:**
2173
2174```ts
2175import { dataSharePredicates } from '@kit.ArkData';
2176
2177async function example() {
2178  console.info('setFavoriteDemo');
2179  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2180  let fetchOption: photoAccessHelper.FetchOptions = {
2181    fetchColumns: [],
2182    predicates: predicates
2183  };
2184  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2185  let asset = await fetchResult.getFirstObject();
2186  asset.setFavorite(true, (err) => {
2187    if (err === undefined) {
2188      console.info('favorite successfully');
2189    } else {
2190      console.error(`favorite failed with error: ${err.code}, ${err.message}`);
2191    }
2192  });
2193}
2194```
2195
2196### setFavorite<sup>(deprecated)</sup>
2197
2198setFavorite(favoriteState: boolean): Promise&lt;void&gt;
2199
2200将文件设置为收藏文件,使用promise方式返回异步结果。
2201
2202> **说明:**
2203>
2204> 从API version 10开始支持,从API version 11开始废弃。建议使用[MediaAssetChangeRequest.setFavorite](#setfavorite11)替代。
2205
2206**系统接口**:此接口为系统接口。
2207
2208**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
2209
2210**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
2211
2212**参数:**
2213
2214| 参数名        | 类型      | 必填   | 说明                                 |
2215| ---------- | ------- | ---- | ---------------------------------- |
2216| favoriteState | boolean | 是    | 是否设置为收藏文件, true:设置为收藏文件,false:取消收藏。 |
2217
2218**返回值:**
2219
2220| 类型                  | 说明         |
2221| ------------------- | ---------- |
2222| Promise&lt;void&gt; | Promise对象,返回void。 |
2223
2224**错误码:**
2225
2226接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
2227
2228| 错误码ID | 错误信息 |
2229| -------- | ---------------------------------------- |
2230| 202        |  Called by non-system application.         |
2231| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2232| 13900012     | Permission denied.         |
2233| 13900020     | Invalid argument.         |
2234| 14000011       | System inner fail.         |
2235
2236**示例:**
2237
2238```ts
2239import { dataSharePredicates } from '@kit.ArkData';
2240import { BusinessError } from '@kit.BasicServicesKit';
2241
2242async function example() {
2243  console.info('setFavoriteDemo');
2244  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2245  let fetchOption: photoAccessHelper.FetchOptions = {
2246    fetchColumns: [],
2247    predicates: predicates
2248  };
2249  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2250  let asset = await fetchResult.getFirstObject();
2251  asset.setFavorite(true).then(() => {
2252    console.info('setFavorite successfully');
2253  }).catch((err: BusinessError) => {
2254    console.error(`setFavorite failed with error: ${err.code}, ${err.message}`);
2255  });
2256}
2257```
2258
2259### setHidden<sup>(deprecated)</sup>
2260
2261setHidden(hiddenState: boolean, callback: AsyncCallback&lt;void&gt;): void
2262
2263将文件设置为隐私文件,使用callback方式返回异步结果。
2264
2265隐私文件存在隐私相册中,用户通过隐私相册去获取隐私文件后可以通过设置hiddenState为false来从隐私相册中移除。
2266
2267> **说明:**
2268>
2269> 从API version 10开始支持,从API version 11开始废弃。建议使用[MediaAssetChangeRequest.setHidden](#sethidden11)替代。
2270
2271**系统接口**:此接口为系统接口。
2272
2273**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
2274
2275**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
2276
2277**参数:**
2278
2279| 参数名        | 类型                        | 必填   | 说明                                 |
2280| ---------- | ------------------------- | ---- | ---------------------------------- |
2281| hiddenState | boolean                   | 是    | 是否设置为隐藏文件,true:将文件资产放入隐藏相册;false:从隐藏相册中恢复。 |
2282| callback   | AsyncCallback&lt;void&gt; | 是    | callback返回void。                              |
2283
2284**错误码:**
2285
2286接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
2287
2288| 错误码ID | 错误信息 |
2289| -------- | ---------------------------------------- |
2290| 202        |  Called by non-system application.         |
2291| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2292| 13900012     | Permission denied.         |
2293| 13900020     | Invalid argument.         |
2294| 14000011       | System inner fail.         |
2295
2296**示例:**
2297
2298```ts
2299import { dataSharePredicates } from '@kit.ArkData';
2300
2301async function example() {
2302  console.info('setHiddenDemo');
2303  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2304  let fetchOption: photoAccessHelper.FetchOptions = {
2305    fetchColumns: [],
2306    predicates: predicates
2307  };
2308  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
2309  let asset = await fetchResult.getFirstObject();
2310  asset.setHidden(true, (err) => {
2311    if (err === undefined) {
2312      console.info('setHidden successfully');
2313    } else {
2314      console.error(`setHidden failed with error: ${err.code}, ${err.message}`);
2315    }
2316  });
2317}
2318```
2319
2320### setHidden<sup>(deprecated)</sup>
2321
2322setHidden(hiddenState: boolean): Promise&lt;void&gt;
2323
2324将文件设置为隐私文件,使用promise方式返回异步结果。
2325
2326隐私文件存在隐私相册中,用户通过隐私相册去获取隐私文件后可以通过设置hiddenState为false来从隐私相册中移除。
2327
2328> **说明:**
2329>
2330> 从API version 10开始支持,从API version 11开始废弃。建议使用[MediaAssetChangeRequest.setHidden](#sethidden11)替代。
2331
2332**系统接口**:此接口为系统接口。
2333
2334**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
2335
2336**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
2337
2338**参数:**
2339
2340| 参数名        | 类型      | 必填   | 说明                                 |
2341| ---------- | ------- | ---- | ---------------------------------- |
2342| hiddenState | boolean | 是    | 是否设置为隐藏文件,true:将文件资产放入隐藏相册;false:从隐藏相册中恢复。 |
2343
2344**返回值:**
2345
2346| 类型                  | 说明         |
2347| ------------------- | ---------- |
2348| Promise&lt;void&gt; | Promise对象,返回void。 |
2349
2350**错误码:**
2351
2352接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
2353
2354| 错误码ID | 错误信息 |
2355| -------- | ---------------------------------------- |
2356| 202        |  Called by non-system application.         |
2357| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2358| 13900012     | Permission denied.         |
2359| 13900020     | Invalid argument.         |
2360| 14000011       | System inner fail.         |
2361
2362**示例:**
2363
2364```ts
2365import { dataSharePredicates } from '@kit.ArkData';
2366import { BusinessError } from '@kit.BasicServicesKit';
2367
2368async function example() {
2369  // 示例代码为将文件从隐藏相册中恢复,需要先在隐藏相册预置资源。
2370  console.info('setHiddenDemo');
2371  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2372  let fetchOption: photoAccessHelper.FetchOptions = {
2373    fetchColumns: [],
2374    predicates: predicates
2375  };
2376  let albumList: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.HIDDEN);
2377  let album = await albumList.getFirstObject();
2378  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
2379  let asset = await fetchResult.getFirstObject();
2380  asset.setHidden(false).then(() => {
2381    console.info('setHidden successfully');
2382  }).catch((err: BusinessError) => {
2383    console.error(`setHidden failed with error: ${err.code}, ${err.message}`);
2384  });
2385}
2386```
2387
2388### getExif
2389
2390getExif(): Promise&lt;string&gt;
2391
2392返回jpg格式图片Exif标签组成的json格式的字符串,该方法使用Promise方式返回结果。
2393
2394此接口中获取的Exif标签信息是由[image](../apis-image-kit/js-apis-image.md)模块提供。Exif标签详细信息请参考[image.PropertyKey](../apis-image-kit/js-apis-image.md#propertykey7)。
2395
2396**注意**:此接口返回的是Exif标签组成的json格式的字符串,完整Exif信息由all_exif与[PhotoKeys.USER_COMMENT](#photokeys)组成,fetchColumns需要传入这两个字段。
2397
2398**系统接口**:此接口为系统接口。
2399
2400**需要权限**:ohos.permission.READ_IMAGEVIDEO
2401
2402**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
2403
2404**返回值:**
2405
2406| 类型                                    | 说明              |
2407| --------------------------------------- | ----------------- |
2408| Promise&lt;string&gt; | 返回Exif标签组成的json格式的字符串。 |
2409
2410**错误码:**
2411
2412接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
2413
2414| 错误码ID | 错误信息 |
2415| -------- | ---------------------------------------- |
2416| 202        |  Called by non-system application.         |
2417| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2418| 13900012     | Permission denied.         |
2419| 13900020     | Invalid argument.         |
2420| 14000011       | System inner fail.         |
2421
2422**示例:**
2423
2424```ts
2425import { dataSharePredicates } from '@kit.ArkData';
2426
2427async function example() {
2428  try {
2429    console.info('getExifDemo');
2430    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2431    let fetchOptions: photoAccessHelper.FetchOptions = {
2432      fetchColumns: [ 'all_exif',  photoAccessHelper.PhotoKeys.USER_COMMENT],
2433      predicates: predicates
2434    };
2435    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
2436    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2437    let exifMessage = await photoAsset.getExif();
2438    let userCommentKey = 'UserComment';
2439    let userComment = JSON.stringify(JSON.parse(exifMessage), [userCommentKey]);
2440    console.info('getExifDemo userComment: ' + JSON.stringify(userComment));
2441    fetchResult.close();
2442  } catch (err) {
2443    console.error(`getExifDemoCallback failed with error: ${err.code}, ${err.message}`);
2444  }
2445}
2446```
2447
2448### getExif
2449
2450getExif(callback: AsyncCallback&lt;string&gt;): void
2451
2452返回jpg格式图片Exif标签组成的json格式的字符串,使用callback方式返回异步结果。
2453
2454此接口中获取的Exif标签信息是由[image](../apis-image-kit/js-apis-image.md)模块提供。Exif标签详细信息请参考[image.PropertyKey](../apis-image-kit/js-apis-image.md#propertykey7)。
2455
2456**注意**:此接口返回的是Exif标签组成的json格式的字符串,完整Exif信息由all_exif与[PhotoKeys.USER_COMMENT](#photokeys)组成,fetchColumns需要传入这两个字段。
2457
2458**系统接口**:此接口为系统接口。
2459
2460**需要权限**:ohos.permission.READ_IMAGEVIDEO
2461
2462**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
2463
2464**参数:**
2465
2466| 参数名   | 类型                      | 必填 | 说明       |
2467| -------- | ------------------------- | ---- | ---------- |
2468| callback | AsyncCallback&lt;string&gt; | 是   | 返回Exif字段组成的json格式的字符串。 |
2469
2470**错误码:**
2471
2472接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
2473
2474| 错误码ID | 错误信息 |
2475| -------- | ---------------------------------------- |
2476| 202        |  Called by non-system application.         |
2477| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2478| 13900012     | Permission denied.         |
2479| 13900020     | Invalid argument.         |
2480| 14000011       | System inner fail.         |
2481
2482**示例:**
2483
2484```ts
2485import { dataSharePredicates } from '@kit.ArkData';
2486
2487async function example() {
2488  try {
2489    console.info('getExifDemo');
2490    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2491    predicates.isNotNull('all_exif')
2492    let fetchOptions: photoAccessHelper.FetchOptions = {
2493      fetchColumns: ['all_exif', photoAccessHelper.PhotoKeys.USER_COMMENT],
2494      predicates: predicates
2495    };
2496    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
2497    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2498    console.info('getExifDemo photoAsset displayName: ' + JSON.stringify(photoAsset.displayName));
2499    let userCommentKey = 'UserComment';
2500    photoAsset.getExif((err, exifMessage) => {
2501      if (exifMessage !== undefined) {
2502        let userComment = JSON.stringify(JSON.parse(exifMessage), [userCommentKey]);
2503        console.info('getExifDemo userComment: ' + JSON.stringify(userComment));
2504      } else {
2505        console.error(`getExif failed, error: ${err.code}, ${err.message}`);
2506      }
2507    });
2508    fetchResult.close();
2509  } catch (err) {
2510    console.error(`getExifDemoCallback failed with error: ${err.code}, ${err.message}`);
2511  }
2512}
2513```
2514
2515### setUserComment<sup>(deprecated)</sup>
2516
2517setUserComment(userComment: string): Promise&lt;void&gt;
2518
2519修改图片或者视频的备注信息,该方法使用Promise来返回结果。
2520
2521> **说明:**
2522>
2523> 从API version 10开始支持,从API version 11开始废弃。建议使用[MediaAssetChangeRequest.setUserComment](#setusercomment11)替代。
2524
2525**注意**:此接口只可修改图片或者视频的备注信息。
2526
2527**系统接口**:此接口为系统接口。
2528
2529**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
2530
2531**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
2532
2533**参数:**
2534
2535| 参数名   | 类型                      | 必填 | 说明       |
2536| -------- | ------------------------- | ---- | ---------- |
2537| userComment | string | 是   | 待修改的图片或视频的备注信息,备注信息最长为420字符。 |
2538
2539**返回值:**
2540
2541| 类型                                    | 说明              |
2542| --------------------------------------- | ----------------- |
2543|Promise&lt;void&gt; | Promise对象,返回void。 |
2544
2545**错误码:**
2546
2547接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
2548
2549| 错误码ID | 错误信息 |
2550| -------- | ---------------------------------------- |
2551| 202        |  Called by non-system application.         |
2552| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2553| 13900012     | Permission denied.         |
2554| 13900020     | Invalid argument.         |
2555| 14000011       | System inner fail.         |
2556
2557**示例:**
2558
2559```ts
2560import { dataSharePredicates } from '@kit.ArkData';
2561
2562async function example() {
2563  try {
2564    console.info('setUserCommentDemo')
2565    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2566    let fetchOptions: photoAccessHelper.FetchOptions = {
2567      fetchColumns: [],
2568      predicates: predicates
2569    };
2570    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
2571    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2572    let userComment = 'test_set_user_comment';
2573    await photoAsset.setUserComment(userComment);
2574  } catch (err) {
2575    console.error(`setUserCommentDemoPromise failed with error: ${err.code}, ${err.message}`);
2576  }
2577}
2578```
2579
2580### setUserComment<sup>(deprecated)</sup>
2581
2582setUserComment(userComment: string, callback: AsyncCallback&lt;void&gt;): void
2583
2584修改图片或者视频的备注信息,该方法使用callback形式来返回结果。
2585
2586> **说明:**
2587>
2588> 从API version 10开始支持,从API version 11开始废弃。建议使用[MediaAssetChangeRequest.setUserComment](#setusercomment11)替代。
2589
2590**注意**:此接口只可修改图片或者视频的备注信息。
2591
2592**系统接口**:此接口为系统接口。
2593
2594**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
2595
2596**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
2597
2598**参数:**
2599
2600| 参数名   | 类型                      | 必填 | 说明       |
2601| -------- | ------------------------- | ---- | ---------- |
2602| userComment | string | 是   | 待修改的图片或视频的备注信息,备注信息最长为420字符。 |
2603| callback | AsyncCallback&lt;void&gt; | 是   | callback返回void。 |
2604
2605**错误码:**
2606
2607接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
2608
2609| 错误码ID | 错误信息 |
2610| -------- | ---------------------------------------- |
2611| 202        |  Called by non-system application.         |
2612| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2613| 13900012     | Permission denied.         |
2614| 13900020     | Invalid argument.         |
2615| 14000011       | System inner fail.         |
2616
2617**示例:**
2618
2619```ts
2620import { dataSharePredicates } from '@kit.ArkData';
2621
2622async function example() {
2623  try {
2624    console.info('setUserCommentDemo')
2625    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2626    let fetchOptions: photoAccessHelper.FetchOptions = {
2627      fetchColumns: [],
2628      predicates: predicates
2629    };
2630    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
2631    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2632    let userComment = 'test_set_user_comment';
2633    photoAsset.setUserComment(userComment, (err) => {
2634      if (err === undefined) {
2635        console.info('setUserComment successfully');
2636      } else {
2637        console.error(`setUserComment failed with error: ${err.code}, ${err.message}`);
2638      }
2639    });
2640  } catch (err) {
2641    console.error(`setUserCommentDemoCallback failed with error: ${err.code}, ${err.message}`);
2642  }
2643}
2644```
2645
2646### setPending<sup>11+</sup>
2647
2648setPending(pendingState: boolean, callback: AsyncCallback&lt;void&gt;): void
2649
2650为图片或视频资源设置pending状态,该方法使用callback形式来返回结果。
2651
2652将文件通过`setPending(true)`设置为pending状态后,只能通过`setPending(false)`解除pending状态。可以通过`photoAsset.get(photoAccessHelper.PhotoKeys.PENDING)`的方式获取是否为pending状态,pending状态下返回true,否则返回false。
2653
2654**注意**:setPending只能在文件的创建期使用,在文件的首次创建流程的close之后,无法通过setPending(true)将文件设置为pending状态。
2655
2656**系统接口**:此接口为系统接口。
2657
2658**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
2659
2660**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
2661
2662**参数:**
2663
2664| 参数名        | 类型      | 必填   | 说明                                 |
2665| ---------- | ------- | ---- | ---------------------------------- |
2666| pendingState | boolean | 是    | 设置的pending状态,true为设置pending状态,false为解除pending状态。 |
2667| callback | AsyncCallback&lt;void&gt; | 是    | Callback对象,返回void。 |
2668
2669**错误码:**
2670
2671接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
2672
2673| 错误码ID | 错误信息 |
2674| -------- | ---------------------------------------- |
2675| 201   | Permission denied.        |
2676| 202   | Called by non-system application.         |
2677| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2678| 14000011   | System inner fail.        |
2679
2680**示例:**
2681
2682```ts
2683async function example() {
2684  try {
2685    console.info('setPendingCallbackDemo');
2686    let testFileName: string = 'testFile' + Date.now() + '.jpg';
2687    let photoAsset = await phAccessHelper.createAsset(testFileName);
2688    let fd = await photoAsset.open('rw');
2689    photoAsset.setPending(true, async (err) => {
2690      if (err !== undefined) {
2691        console.error(`setPending(true) failed with error: ${err.code}, ${err.message}`);
2692        return;
2693      }
2694      // write photo buffer in fd.
2695      photoAsset.setPending(false, async (err) => {
2696        if (err !== undefined) {
2697          console.error(`setPending(false) failed with error: ${err.code}, ${err.message}`);
2698          return;
2699        }
2700        await photoAsset.close(fd);
2701      });
2702    });
2703  } catch (err) {
2704    console.error(`setPendingCallbackDemo failed with error: ${err.code}, ${err.message}`);
2705  }
2706}
2707```
2708
2709### setPending<sup>11+</sup>
2710
2711setPending(pendingState: boolean): Promise&lt;void&gt;
2712
2713为图片或视频资源设置pending状态,该方法使用promise形式来返回结果。
2714
2715将文件通过`setPending(true)`设置为pending状态后,只能通过`setPending(false)`解除pending状态。可以通过`photoAsset.get(photoAccessHelper.PhotoKeys.PENDING)`的方式获取是否为pending状态,pending状态下返回true,否则返回false。
2716
2717**注意**:setPending只能在文件的创建期使用,在文件的首次创建流程的close之后,无法通过setPending(true)将文件设置为pending状态。
2718
2719**系统接口**:此接口为系统接口。
2720
2721**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
2722
2723**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
2724
2725**参数:**
2726
2727| 参数名        | 类型      | 必填   | 说明                                 |
2728| ---------- | ------- | ---- | ---------------------------------- |
2729| pendingState | boolean | 是    | 设置的pending状态,true为设置pending状态,false为解除pending状态。 |
2730
2731**返回值:**
2732
2733| 类型                                    | 说明              |
2734| --------------------------------------- | ----------------- |
2735|Promise&lt;boolean&gt; | Promise对象,返回void。 |
2736
2737**错误码:**
2738
2739接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
2740
2741| 错误码ID | 错误信息 |
2742| -------- | ---------------------------------------- |
2743| 201   | Permission denied.        |
2744| 202   | Called by non-system application.         |
2745| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2746| 14000011   | System inner fail.        |
2747
2748**示例:**
2749
2750```ts
2751async function example() {
2752  try {
2753    console.info('setPendingPromiseDemo');
2754    let testFileName: string = 'testFile' + Date.now() + '.jpg';
2755    let photoAsset = await phAccessHelper.createAsset(testFileName);
2756    let fd = await photoAsset.open('rw');
2757    await photoAsset.setPending(true);
2758    // write photo buffer in fd.
2759    photoAsset.setPending(false);
2760    await photoAsset.close(fd);
2761  } catch (err) {
2762    console.error(`setPendingPromiseDemo failed with error: ${err.code}, ${err.message}`);
2763  }
2764}
2765```
2766
2767### isEdited<sup>11+</sup>
2768
2769isEdited(callback: AsyncCallback&lt;boolean&gt;): void
2770
2771查询图片或视频资源是否被编辑过,该方法使用callback形式来返回结果。
2772
2773**系统接口**:此接口为系统接口。
2774
2775**需要权限**:ohos.permission.READ_IMAGEVIDEO
2776
2777**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
2778
2779**参数:**
2780
2781| 参数名        | 类型      | 必填   | 说明                                 |
2782| ---------- | ------- | ---- | ---------------------------------- |
2783| callback | AsyncCallback&lt;boolean&gt; | 是    | Callback对象,返回图片或视频资源是否被编辑过。true为被编辑过,false为没有被编辑过,默认是false。 |
2784
2785**错误码:**
2786
2787接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
2788
2789| 错误码ID | 错误信息 |
2790| -------- | ---------------------------------------- |
2791| 201   | Permission denied.        |
2792| 202   | Called by non-system application.         |
2793| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2794| 14000011   | System inner fail.        |
2795
2796**示例:**
2797
2798```ts
2799import { dataSharePredicates } from '@kit.ArkData';
2800
2801async function example() {
2802  try {
2803    console.info('isEditedCallbackDemo')
2804    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2805    let fetchOptions: photoAccessHelper.FetchOptions = {
2806      fetchColumns: [],
2807      predicates: predicates
2808    };
2809    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
2810    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2811    photoAsset.isEdited((err, isEdited) => {
2812      if (err === undefined) {
2813        if (isEdited === true) {
2814          console.info('Photo is edited');
2815        } else {
2816          console.info('Photo is not edited');
2817        }
2818      } else {
2819        console.error(`isEdited failed with error: ${err.code}, ${err.message}`);
2820      }
2821    });
2822  } catch (err) {
2823    console.error(`isEditedDemoCallback failed with error: ${err.code}, ${err.message}`);
2824  }
2825}
2826```
2827
2828### isEdited<sup>11+</sup>
2829
2830isEdited(): Promise&lt;boolean&gt;
2831
2832查询图片或视频资源是否被编辑过,该方法使用promise形式来返回结果。
2833
2834**系统接口**:此接口为系统接口。
2835
2836**需要权限**:ohos.permission.READ_IMAGEVIDEO
2837
2838**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
2839
2840**返回值:**
2841
2842| 类型                                    | 说明              |
2843| --------------------------------------- | ----------------- |
2844|Promise&lt;boolean&gt; | Promise对象,返回图片或视频资源是否被编辑过。true为被编辑过,false为没有被编辑过,默认是false。 |
2845
2846
2847**错误码:**
2848
2849接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
2850
2851| 错误码ID | 错误信息 |
2852| -------- | ---------------------------------------- |
2853| 201   | Permission denied.        |
2854| 202   | Called by non-system application.         |
2855| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2856| 14000011   | System inner fail.        |
2857
2858**示例:**
2859
2860```ts
2861import { dataSharePredicates } from '@kit.ArkData';
2862
2863async function example() {
2864  try {
2865    console.info('isEditedPromiseDemo')
2866    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2867    let fetchOptions: photoAccessHelper.FetchOptions = {
2868      fetchColumns: [],
2869      predicates: predicates
2870    };
2871    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
2872    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2873    let isEdited = await photoAsset.isEdited();
2874    if (isEdited === true) {
2875      console.info('Photo is edited');
2876    } else {
2877      console.info('Photo is not edited');
2878    }
2879  } catch (err) {
2880    console.error(`isEditedDemoCallback failed with error: ${err.code}, ${err.message}`);
2881  }
2882}
2883```
2884
2885### requestEditData<sup>11+</sup>
2886
2887requestEditData(callback: AsyncCallback&lt;string&gt;): void
2888
2889获得图片或视频资源的编辑数据,该方法使用callback形式来返回结果。
2890
2891如果资源未编辑过,则返回一个空字符串。
2892
2893**系统接口**:此接口为系统接口。
2894
2895**需要权限**:ohos.permission.READ_IMAGEVIDEO
2896
2897**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
2898
2899**参数:**
2900
2901| 参数名        | 类型      | 必填   | 说明                                 |
2902| ---------- | ------- | ---- | ---------------------------------- |
2903| callback | AsyncCallback&lt;string&gt; | 是    | Callback对象,返回图片或视频资源的编辑数据。 |
2904
2905**错误码:**
2906
2907接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
2908
2909| 错误码ID | 错误信息 |
2910| -------- | ---------------------------------------- |
2911| 201   | Permission denied.        |
2912| 202   | Called by non-system application.         |
2913| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2914| 14000011   | System inner fail.        |
2915
2916**示例:**
2917
2918```ts
2919import { dataSharePredicates } from '@kit.ArkData';
2920
2921async function example() {
2922  try {
2923    console.info('requestEditDataCallbackDemo')
2924    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2925    let fetchOptions: photoAccessHelper.FetchOptions = {
2926      fetchColumns: [],
2927      predicates: predicates
2928    };
2929    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
2930    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2931    photoAsset.requestEditData((err, editdata) => {
2932      if (err === undefined) {
2933        console.info('Editdata is ' + editdata);
2934      } else {
2935        console.error(`requestEditData failed with error: ${err.code}, ${err.message}`);
2936      }
2937    });
2938  } catch (err) {
2939    console.error(`requestEditDataCallbackDemo failed with error: ${err.code}, ${err.message}`);
2940  }
2941}
2942```
2943
2944### requestEditData<sup>11+</sup>
2945
2946requestEditData(): Promise&lt;string&gt;
2947
2948获得图片或视频资源的编辑数据,该方法使用promise形式来返回结果。
2949
2950如果资源未编辑过,则返回一个空字符串。
2951
2952**系统接口**:此接口为系统接口。
2953
2954**需要权限**:ohos.permission.READ_IMAGEVIDEO
2955
2956**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
2957
2958**返回值:**
2959
2960| 类型                                    | 说明              |
2961| --------------------------------------- | ----------------- |
2962|Promise&lt;string&gt; | Promise对象,返回图片或视频资源的编辑数据。 |
2963
2964
2965**错误码:**
2966
2967接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
2968
2969| 错误码ID | 错误信息 |
2970| -------- | ---------------------------------------- |
2971| 201   | Permission denied.        |
2972| 202   | Called by non-system application.         |
2973| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2974| 14000011   | System inner fail.        |
2975
2976**示例:**
2977
2978```ts
2979import { dataSharePredicates } from '@kit.ArkData';
2980
2981async function example() {
2982  try {
2983    console.info('requestEditDataPromiseDemo')
2984    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
2985    let fetchOptions: photoAccessHelper.FetchOptions = {
2986      fetchColumns: [],
2987      predicates: predicates
2988    };
2989    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
2990    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
2991    let editdata: string = await photoAsset.requestEditData();
2992    console.info('Editdata is ' + editdata);
2993  } catch (err) {
2994    console.error(`requestEditDataPromiseDemo failed with error: ${err.code}, ${err.message}`);
2995  }
2996}
2997```
2998
2999### getEditData<sup>11+</sup>
3000
3001getEditData(): Promise&lt;MediaAssetEditData&gt;
3002
3003获得资产编辑数据,该方法使用promise形式来返回结果。
3004
3005如果资源未编辑过,则返回的编辑数据的内容为空字符串。
3006
3007**系统接口**:此接口为系统接口。
3008
3009**需要权限**:ohos.permission.READ_IMAGEVIDEO
3010
3011**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
3012
3013**返回值:**
3014
3015| 类型                                    | 说明              |
3016| --------------------------------------- | ----------------- |
3017|Promise&lt;[MediaAssetEditData](#mediaasseteditdata11)&gt; | Promise对象,返回资产编辑数据。 |
3018
3019**错误码:**
3020
3021接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
3022
3023| 错误码ID | 错误信息 |
3024| -------- | ---------------------------------------- |
3025| 201   | Permission denied.        |
3026| 202   | Called by non-system application.         |
3027| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3028| 14000011   | System inner fail.        |
3029
3030**示例:**
3031
3032```ts
3033import { dataSharePredicates } from '@kit.ArkData';
3034
3035async function example() {
3036  try {
3037    console.info('getEditDataDemo')
3038    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3039    let fetchOptions: photoAccessHelper.FetchOptions = {
3040      fetchColumns: [],
3041      predicates: predicates
3042    };
3043    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3044    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3045    let assetEditData: photoAccessHelper.MediaAssetEditData = await photoAsset.getEditData();
3046    let data: string = assetEditData.data;
3047    console.info('edit data is ' + data);
3048  } catch (err) {
3049    console.error(`getEditDataDemo failed with error: ${err.code}, ${err.message}`);
3050  }
3051}
3052```
3053
3054### requestSource<sup>11+</sup>
3055
3056requestSource(callback: AsyncCallback&lt;number&gt;): void
3057
3058打开源文件并返回fd,该方法使用callback形式来返回结果。
3059
3060**系统接口**:此接口为系统接口。
3061
3062**需要权限**:ohos.permission.READ_IMAGEVIDEO
3063
3064**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
3065
3066**参数:**
3067
3068| 参数名        | 类型      | 必填   | 说明                                 |
3069| ---------- | ------- | ---- | ---------------------------------- |
3070| callback | AsyncCallback&lt;number&gt; | 是    | Callback对象,返回源文件fd。 |
3071
3072**错误码:**
3073
3074接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
3075
3076| 错误码ID | 错误信息 |
3077| -------- | ---------------------------------------- |
3078| 201   | Permission denied.        |
3079| 202   | Called by non-system application.         |
3080| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3081| 14000011   | System inner fail.        |
3082
3083**示例:**
3084
3085```ts
3086import { dataSharePredicates } from '@kit.ArkData';
3087
3088async function example() {
3089  try {
3090    console.info('requsetSourceCallbackDemo')
3091    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3092    let fetchOptions: photoAccessHelper.FetchOptions = {
3093      fetchColumns: [],
3094      predicates: predicates
3095    };
3096    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3097    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3098    photoAsset.requestSource((err, fd) => {
3099      if (err === undefined) {
3100        console.info('Source fd is ' + fd);
3101      } else {
3102        console.error(`requestSource failed with error: ${err.code}, ${err.message}`);
3103      }
3104    });
3105  } catch (err) {
3106    console.error(`requsetSourceCallbackDemo failed with error: ${err.code}, ${err.message}`);
3107  }
3108}
3109```
3110
3111### requestSource<sup>11+</sup>
3112
3113requestSource(): Promise&lt;number&gt;
3114
3115打开源文件并返回fd,该方法使用promise形式来返回结果。
3116
3117**系统接口**:此接口为系统接口。
3118
3119**需要权限**:ohos.permission.READ_IMAGEVIDEO
3120
3121**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
3122
3123**返回值:**
3124
3125| 类型                                    | 说明              |
3126| --------------------------------------- | ----------------- |
3127|Promise&lt;number&gt; | Promise对象,返回源文件fd。 |
3128
3129**错误码:**
3130
3131接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
3132
3133| 错误码ID | 错误信息 |
3134| -------- | ---------------------------------------- |
3135| 201   | Permission denied.        |
3136| 202   | Called by non-system application.         |
3137| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3138| 14000011   | System inner fail.        |
3139
3140**示例:**
3141
3142```ts
3143import { dataSharePredicates } from '@kit.ArkData';
3144
3145async function example() {
3146  try {
3147    console.info('requsetSourcePromiseDemo')
3148    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3149    let fetchOptions: photoAccessHelper.FetchOptions = {
3150      fetchColumns: [],
3151      predicates: predicates
3152    };
3153    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3154    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3155    let fd = await photoAsset.requestSource();
3156    console.info('Source fd is ' + fd);
3157  } catch (err) {
3158    console.error(`requsetSourcePromiseDemo failed with error: ${err.code}, ${err.message}`);
3159  }
3160}
3161```
3162
3163### commitEditedAsset<sup>11+</sup>
3164
3165commitEditedAsset(editData: string, uri: string, callback: AsyncCallback&lt;void&gt;)
3166
3167提交编辑数据以及编辑后的图片或视频,该方法使用callback形式来返回结果。
3168
3169通过uri将编辑后的文件传递给媒体库,uri是编辑后的文件在应用沙箱下的FileUri,可参考[FileUri](../apis-core-file-kit/js-apis-file-fileuri.md)。
3170
3171**注意**:新的编辑数据提交后,将覆盖掉原来的编辑数据。
3172
3173**系统接口**:此接口为系统接口。
3174
3175**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
3176
3177**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
3178
3179**参数:**
3180
3181| 参数名        | 类型      | 必填   | 说明                                 |
3182| ---------- | ------- | ---- | ---------------------------------- |
3183| editData | string | 是    | 提交的编辑数据。 |
3184| uri | string | 是    | 提交的编辑后的图片或视频,在应用沙箱下的uri。 |
3185| callback | AsyncCallback&lt;void&gt; | 是    | Callback对象,返回void。 |
3186
3187**错误码:**
3188
3189接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
3190
3191| 错误码ID | 错误信息 |
3192| -------- | ---------------------------------------- |
3193| 201   | Permission denied.        |
3194| 202   | Called by non-system application.         |
3195| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3196| 14000011   | System inner fail.        |
3197
3198**示例:**
3199
3200```ts
3201import { dataSharePredicates } from '@kit.ArkData';
3202
3203async function example() {
3204  try {
3205    console.info('commitEditedAssetCallbackDemo')
3206    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3207    let fetchOptions: photoAccessHelper.FetchOptions = {
3208      fetchColumns: [],
3209      predicates: predicates
3210    };
3211    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3212    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3213    let editData = '123456';
3214    let uri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
3215    photoAsset.commitEditedAsset(editData, uri, (err) => {
3216      if (err === undefined) {
3217        console.info('commitEditedAsset is successful');
3218      } else {
3219        console.error(`commitEditedAsset failed with error: ${err.code}, ${err.message}`);
3220      }
3221    });
3222  } catch (err) {
3223    console.error(`commitEditedAssetCallbackDemo failed with error: ${err.code}, ${err.message}`);
3224  }
3225}
3226```
3227
3228### commitEditedAsset<sup>11+</sup>
3229
3230commitEditedAsset(editData: string, uri: string): Promise&lt;void&gt;
3231
3232提交编辑数据以及编辑后的图片或视频,该方法使用promise形式来返回结果。
3233
3234通过uri将编辑后的文件传递给媒体库,uri是编辑后的文件在应用沙箱下的FileUri,可参考[FileUri](../apis-core-file-kit/js-apis-file-fileuri.md)。
3235
3236**注意**:新的编辑数据提交后,将覆盖掉原来的编辑数据。
3237
3238**系统接口**:此接口为系统接口。
3239
3240**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
3241
3242**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
3243
3244**参数:**
3245
3246| 参数名        | 类型      | 必填   | 说明                                 |
3247| ---------- | ------- | ---- | ---------------------------------- |
3248| editData | string | 是    | 提交的编辑数据。 |
3249| uri | string | 是    | 提交的编辑后的图片或视频,在应用沙箱下的uri。 |
3250
3251**返回值:**
3252
3253| 类型                                    | 说明              |
3254| --------------------------------------- | ----------------- |
3255|Promise&lt;void&gt; | Promise对象,返回void。 |
3256
3257**错误码:**
3258
3259接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
3260
3261| 错误码ID | 错误信息 |
3262| -------- | ---------------------------------------- |
3263| 201   | Permission denied.        |
3264| 202   | Called by non-system application.         |
3265| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3266| 14000011   | System inner fail.        |
3267
3268**示例:**
3269
3270```ts
3271import { dataSharePredicates } from '@kit.ArkData';
3272
3273async function example() {
3274  try {
3275    console.info('commitEditedAssetPromiseDemo')
3276    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3277    let fetchOptions: photoAccessHelper.FetchOptions = {
3278      fetchColumns: [],
3279      predicates: predicates
3280    };
3281    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3282    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3283    let editData = '123456';
3284    let uri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
3285    await photoAsset.commitEditedAsset(editData, uri);
3286    console.info('commitEditedAsset is successful');
3287  } catch (err) {
3288    console.error(`commitEditedAssetPromiseDemo failed with error: ${err.code}, ${err.message}`);
3289  }
3290}
3291```
3292
3293### revertToOriginal<sup>11+</sup>
3294
3295revertToOriginal(callback: AsyncCallback&lt;void&gt;)
3296
3297回退到编辑前的状态,该方法使用callback形式来返回结果。
3298
3299**注意**:调用该接口后,编辑数据和编辑后的图片或视频资源都将被删除,无法恢复,请谨慎调用。
3300
3301**系统接口**:此接口为系统接口。
3302
3303**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
3304
3305**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
3306
3307**参数:**
3308
3309| 参数名        | 类型      | 必填   | 说明                                 |
3310| ---------- | ------- | ---- | ---------------------------------- |
3311| callback | AsyncCallback&lt;void&gt; | 是    | Callback对象,返回void。 |
3312
3313**错误码:**
3314
3315接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
3316
3317| 错误码ID | 错误信息 |
3318| -------- | ---------------------------------------- |
3319| 201   | Permission denied.        |
3320| 202   | Called by non-system application.         |
3321| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3322| 14000011   | System inner fail.        |
3323
3324**示例:**
3325
3326```ts
3327import { dataSharePredicates } from '@kit.ArkData';
3328
3329async function example() {
3330  try {
3331    console.info('revertToOriginalCallbackDemo')
3332    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3333    let fetchOptions: photoAccessHelper.FetchOptions = {
3334      fetchColumns: [],
3335      predicates: predicates
3336    };
3337    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3338    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3339    photoAsset.revertToOriginal((err) => {
3340      if (err === undefined) {
3341        console.info('revertToOriginal is successful');
3342      } else {
3343        console.error(`revertToOriginal failed with error: ${err.code}, ${err.message}`);
3344      }
3345    });
3346  } catch (err) {
3347    console.error(`revertToOriginalCallbackDemo failed with error: ${err.code}, ${err.message}`);
3348  }
3349}
3350```
3351
3352### revertToOriginal<sup>11+</sup>
3353
3354revertToOriginal(): Promise&lt;void&gt;
3355
3356回退到编辑前的状态,该方法使用promise形式来返回结果。
3357
3358**注意**:调用该接口后,编辑数据和编辑后的图片或视频资源都将被删除,无法恢复,请谨慎调用。
3359
3360**系统接口**:此接口为系统接口。
3361
3362**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
3363
3364**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
3365
3366**返回值:**
3367
3368| 类型                                    | 说明              |
3369| --------------------------------------- | ----------------- |
3370|Promise&lt;string&gt; | Promise对象,返回void。 |
3371
3372**错误码:**
3373
3374接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
3375
3376| 错误码ID | 错误信息 |
3377| -------- | ---------------------------------------- |
3378| 201   | Permission denied.        |
3379| 202   | Called by non-system application.         |
3380| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3381| 14000011   | System inner fail.        |
3382
3383**示例:**
3384
3385```ts
3386import { dataSharePredicates } from '@kit.ArkData';
3387
3388async function example() {
3389  try {
3390    console.info('revertToOriginalPromiseDemo')
3391    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3392    let fetchOptions: photoAccessHelper.FetchOptions = {
3393      fetchColumns: [],
3394      predicates: predicates
3395    };
3396    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
3397    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3398    photoAsset.revertToOriginal();
3399    console.info('revertToOriginal is successful');
3400  } catch (err) {
3401    console.error(`revertToOriginalPromiseDemo failed with error: ${err.code}, ${err.message}`);
3402  }
3403}
3404```
3405
3406### requestPhoto<sup>11+</sup>
3407
3408requestPhoto(callback: AsyncCallback&lt;image.PixelMap&gt;): string
3409
3410通过callback的形式,获取资源的快速缩略图和普通缩略图。
3411
3412快速缩略图尺寸为128\*128,普通缩略图尺寸为256\*256。应用调用接口后,callback将返回两次缩略图对象,第一次为快速缩略图,第二次为普通缩略图。
3413
3414**系统接口**:此接口为系统接口。
3415
3416**需要权限**:ohos.permission.READ_IMAGEVIDEO
3417
3418**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
3419
3420**参数:**
3421
3422| 参数名        | 类型      | 必填   | 说明                                 |
3423| ---------- | ------- | ---- | ---------------------------------- |
3424| callback | AsyncCallback&lt;[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)&gt; | 是    | Callback对象,返回获取的缩略图,调用2次。 |
3425
3426**返回值:**
3427
3428| 类型                                    | 说明              |
3429| --------------------------------------- | ----------------- |
3430| string | 本次获取任务的id。 |
3431
3432**错误码:**
3433
3434接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
3435
3436| 错误码ID | 错误信息 |
3437| -------- | ---------------------------------------- |
3438| 201   | Permission verification failed, usually the result returned by VerifyAccessToken.        |
3439| 202   | Permission verification failed, application which is not a system application uses system API.         |
3440| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3441| 14000011   | System inner fail.        |
3442
3443**示例:**
3444
3445```ts
3446import { dataSharePredicates } from '@kit.ArkData';
3447import { image } from '@kit.ImageKit';
3448
3449async function example() {
3450  try {
3451    console.info('requestPhotoDemo')
3452    let options: photoAccessHelper.FetchOptions = {
3453      fetchColumns: [],
3454      predicates: new dataSharePredicates.DataSharePredicates()
3455    }
3456    let fetchResult = await phAccessHelper.getAssets(options);
3457    let photoAsset = await fetchResult.getFirstObject();
3458    let taskId: string = photoAsset.requestPhoto(async (err, pixel: image.PixelMap) => {
3459      if (err === undefined) {
3460        console.info("requestSource in, size: " + JSON.stringify((await pixel.getImageInfo()).size))
3461      } else {
3462        console.error(`requestSource failed with error: ${err.code}, ${err.message}`);
3463      }
3464    })
3465    console.info('requestSource taskId: ' + taskId)
3466  } catch (err) {
3467    console.error(`requestPhotoDemo failed with error: ${err.code}, ${err.message}`);
3468  }
3469}
3470```
3471
3472### requestPhoto<sup>11+</sup>
3473
3474requestPhoto(options: RequestPhotoOptions, callback: AsyncCallback&lt;image.PixelMap&gt;): string
3475
3476通过callback的形式,根据传入的选项,获取资源的缩略图。
3477
3478**系统接口**:此接口为系统接口。
3479
3480**需要权限**:ohos.permission.READ_IMAGEVIDEO
3481
3482**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
3483
3484**参数:**
3485
3486| 参数名        | 类型      | 必填   | 说明                                 |
3487| ---------- | ------- | ---- | ---------------------------------- |
3488| options | [RequestPhotoOptions](#requestphotooptions11) | 是    | 获取资源缩略图的选项。 |
3489| callback | AsyncCallback&lt;[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)&gt; | 是    | Callback对象,返回获取的缩略图,根据选项的设置可能调用超过1次。 |
3490
3491**返回值:**
3492
3493| 类型                                    | 说明              |
3494| --------------------------------------- | ----------------- |
3495| string | 本次获取任务的id。 |
3496
3497**错误码:**
3498
3499接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
3500
3501| 错误码ID | 错误信息 |
3502| -------- | ---------------------------------------- |
3503| 201   | Permission verification failed, usually the result returned by VerifyAccessToken.        |
3504| 202   | Permission verification failed, application which is not a system application uses system API.         |
3505| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3506| 14000011   | System inner fail.        |
3507
3508**示例:**
3509
3510```ts
3511import { dataSharePredicates } from '@kit.ArkData';
3512import { image } from '@kit.ImageKit';
3513
3514async function example() {
3515  try {
3516    console.info('requestPhotoDemo')
3517    let options: photoAccessHelper.FetchOptions = {
3518      fetchColumns: [],
3519      predicates: new dataSharePredicates.DataSharePredicates()
3520    }
3521    let fetchResult = await phAccessHelper.getAssets(options);
3522    let photoAsset = await fetchResult.getFirstObject();
3523    let taskId: string = photoAsset.requestPhoto({
3524      "size": {
3525        "width": 256,
3526        "height": 256
3527      },
3528      "requestPhotoType": photoAccessHelper.RequestPhotoType.REQUEST_ALL_THUMBNAILS
3529    }, async (err, pixel: image.PixelMap) => {
3530      if (err === undefined) {
3531        console.info("requestSource in, size: " + JSON.stringify((await pixel.getImageInfo()).size))
3532      } else {
3533        console.error(`requestSource failed with error: ${err.code}, ${err.message}`);
3534      }
3535    })
3536    console.info('requestSource taskId: ' + taskId)
3537  } catch (err) {
3538    console.error(`requestPhotoDemo failed with error: ${err.code}, ${err.message}`);
3539  }
3540}
3541```
3542
3543### cancelPhotoRequest<sup>11+</sup>
3544
3545cancelPhotoRequest(requestId: string): void
3546
3547根据id取消指定的获取媒体缩略图的任务。
3548
3549**系统接口**:此接口为系统接口。
3550
3551**需要权限**:ohos.permission.READ_IMAGEVIDEO
3552
3553**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
3554
3555**参数:**
3556
3557| 参数名        | 类型      | 必填   | 说明                                 |
3558| ---------- | ------- | ---- | ---------------------------------- |
3559| requestId | string | 是    | 待取消的获取媒体缩略图的任务id。 |
3560
3561**错误码:**
3562
3563接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
3564
3565| 错误码ID | 错误信息 |
3566| -------- | ---------------------------------------- |
3567| 201   | Permission verification failed, usually the result returned by VerifyAccessToken.        |
3568| 202   | Permission verification failed, application which is not a system application uses system API.         |
3569| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3570| 14000011   | System inner fail.        |
3571
3572**示例:**
3573
3574```ts
3575import { dataSharePredicates } from '@kit.ArkData';
3576import { image } from '@kit.ImageKit';
3577
3578async function example() {
3579  try {
3580    console.info('cancelPhotoRequestDemo')
3581    let options: photoAccessHelper.FetchOptions = {
3582      fetchColumns: [],
3583      predicates: new dataSharePredicates.DataSharePredicates()
3584    }
3585    let fetchResult = await phAccessHelper.getAssets(options);
3586    let photoAsset = await fetchResult.getFirstObject();
3587    let taskId: string = photoAsset.requestPhoto({
3588      "size": {
3589        "width": 256,
3590        "height": 256
3591      },
3592      "requestPhotoType": photoAccessHelper.RequestPhotoType.REQUEST_ALL_THUMBNAILS
3593    }, async (err, pixel: image.PixelMap) => {
3594      if (err === undefined) {
3595        console.info("requestSource in, size: " + JSON.stringify((await pixel.getImageInfo()).size))
3596      } else {
3597        console.error(`requestSource failed with error: ${err.code}, ${err.message}`);
3598      }
3599    })
3600    console.info('requestSource taskId: ' + taskId)
3601    photoAsset.cancelPhotoRequest(taskId);
3602  } catch (err) {
3603    console.error(`cancelPhotoRequestDemo failed with error: ${err.code}, ${err.message}`);
3604  }
3605}
3606```
3607
3608### getAnalysisData<sup>11+</sup>
3609
3610getAnalysisData(analysisType: AnalysisType): Promise\<string>
3611
3612根据智慧分析类型获取指定分析结果数据。
3613
3614**系统接口**:此接口为系统接口。
3615
3616**需要权限**:ohos.permission.READ\_IMAGEVIDEO
3617
3618**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
3619
3620**参数:**
3621
3622| 参数名          | 类型           | 必填 | 说明           |
3623| :----------- | :----------- | :- | :----------- |
3624| analysisType | [AnalysisType](#analysistype11) | 是  | 需要获取的智慧分析类型。 |
3625
3626**错误码:**
3627
3628接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
3629
3630| 错误码ID    | 错误信息                              |
3631| :------- | :-------------------------------- |
3632| 201      | Permission denied.                |
3633| 202      | Called by non-system application. |
3634| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3635| 14000011 | System inner fail.                |
3636
3637**示例:**
3638
3639```ts
3640import { dataSharePredicates } from '@kit.ArkData';
3641
3642async function example() {
3643  try {
3644    console.info('getAnalysisDataDemo')
3645    let fetchOptions: photoAccessHelper.FetchOptions = {
3646      fetchColumns: [],
3647      predicates: new dataSharePredicates.DataSharePredicates()
3648    }
3649    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> =
3650      await phAccessHelper.getAssets(fetchOptions);
3651    let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3652    if (photoAsset != undefined) {
3653      let analysisData: string = await photoAsset.getAnalysisData(
3654        photoAccessHelper.AnalysisType.ANALYSIS_OCR);
3655      console.info('get ocr result: ' + JSON.stringify(analysisData));
3656    }
3657    fetchResult.close();
3658  } catch (err) {
3659    console.error(`getAnalysisDataDemofailed with error: ${err.code}, ${err.message}`);
3660  }
3661}
3662```
3663
3664### getThumbnailData<sup>18+</sup>
3665
3666getThumbnailData(type: ThumbnailType): Promise&lt;ArrayBuffer&gt;
3667
3668获取文件缩略图的ArrayBuffer,传入缩略图的类型,使用promise异步回调。
3669
3670**需要权限**:ohos.permission.READ_IMAGEVIDEO
3671
3672**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
3673
3674**参数:**
3675
3676| 参数名  | 类型             | 必填   | 说明    |
3677| ---- | -------------- | ---- | ----- |
3678| type | [ThumbnailType](#thumbnailtype13) | 是    | 缩略图类型。 |
3679
3680**返回值:**
3681
3682| 类型                            | 说明                    |
3683| ----------------------------- | --------------------- |
3684| Promise\<ArrayBuffer> | Promise对象,返回缩略图的ArrayBuffer。 |
3685
3686**错误码:**
3687
3688以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
3689
3690| 错误码ID | 错误信息 |
3691| -------- | ---------------------------------------- |
3692| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3693| 202      | Called by non-system application. |
3694| 13900012     | Permission denied.         |
3695| 13900020     | Invalid argument.         |
3696| 14000011       | System inner fail.         |
3697
3698**示例:**
3699
3700```ts
3701import { dataSharePredicates } from '@kit.ArkData';
3702import { BusinessError } from '@kit.BasicServicesKit';
3703import {photoAccessHelper} from '@kit.MediaLibraryKit';
3704import { common } from '@kit.AbilityKit';
3705
3706// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
3707let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
3708let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
3709
3710async function example() {
3711  console.info('getThumbnailDataDemo');
3712  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3713  let fetchOption: photoAccessHelper.FetchOptions = {
3714    fetchColumns: [],
3715    predicates: predicates
3716  };
3717  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
3718  let asset = await fetchResult.getFirstObject();
3719  console.info('asset displayName = ', asset.displayName);
3720  asset.getThumbnailData(photoAccessHelper.ThumbnailType.LCD).then((buffer: ArrayBuffer) => {
3721    console.info('getThumbnailData successful, buffer byteLength = ${buffer.byteLength}');
3722  }).catch((err: BusinessError) => {
3723    console.error(`getThumbnailData fail with error: ${err.code}, ${err.message}`);
3724  });
3725}
3726```
3727
3728## Album
3729
3730实体相册
3731
3732### 属性
3733
3734**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
3735
3736| 名称           | 类型    | 只读   | 可选  | 说明   |
3737| ------------ | ------ | ---- | ---- | ------- |
3738| lpath<sup>18+</sup>    | string | 是    | 是   | 相册虚拟路径。<br>**系统接口**:此接口为系统接口。|
3739| dateAdded<sup>18+</sup>    | number | 是    | 是   | 相册添加时间。<br>**系统接口**:此接口为系统接口。|
3740| dateModified<sup>18+</sup>    | number | 是    | 是   | 相册修改时间。<br>**系统接口**:此接口为系统接口。|
3741
3742### recoverAssets<sup>(deprecated)</sup>
3743
3744recoverAssets(assets: Array&lt;PhotoAsset&gt;, callback: AsyncCallback&lt;void&gt;): void
3745
3746从回收站中恢复图片或者视频,需要先在回收站中预置文件资源。该方法使用callback形式来返回结果。
3747
3748> **说明:**
3749>
3750> 从API version 10开始支持,从API version 11开始废弃。建议使用[MediaAlbumChangeRequest.recoverAssets](#recoverassets11)替代。
3751
3752**系统接口**:此接口为系统接口。
3753
3754**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
3755
3756**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
3757
3758**参数:**
3759
3760| 参数名   | 类型                      | 必填 | 说明       |
3761| -------- | ------------------------- | ---- | ---------- |
3762| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | 是   | 回收站中待恢复图片或者视频数组。 |
3763| callback | AsyncCallback&lt;void&gt; | 是   | callback返回void。 |
3764
3765**错误码:**
3766
3767接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
3768
3769| 错误码ID | 错误信息 |
3770| -------- | ---------------------------------------- |
3771| 202      |  Called by non-system application.         |
3772| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3773| 13900012     | Permission denied.         |
3774| 13900020     | Invalid argument.         |
3775| 14000011       | System inner fail.         |
3776
3777**示例:**
3778
3779```ts
3780import { dataSharePredicates } from '@kit.ArkData';
3781
3782async function example() {
3783  try {
3784    console.info('recoverAssetsDemoCallback');
3785    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3786    let fetchOption: photoAccessHelper.FetchOptions = {
3787      fetchColumns: [],
3788      predicates: predicates
3789    };
3790    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH);
3791    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
3792    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
3793    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3794    album.recoverAssets([asset], (err) => {
3795      if (err === undefined) {
3796        console.info('album recoverAssets successfully');
3797      } else {
3798        console.error(`album recoverAssets failed with error: ${err.code}, ${err.message}`);
3799      }
3800    });
3801  } catch (err) {
3802    console.error(`recoverAssetsDemoCallback failed with error: ${err.code}, ${err.message}`);
3803  }
3804}
3805```
3806
3807### recoverAssets<sup>(deprecated)</sup>
3808
3809recoverAssets(assets: Array&lt;PhotoAsset&gt;): Promise&lt;void&gt;
3810
3811从回收站中恢复图片或者视频,需要先在回收站中预置文件资源。该方法使用Promise来返回结果。
3812
3813> **说明:**
3814>
3815> 从API version 10开始支持,从API version 11开始废弃。建议使用[MediaAlbumChangeRequest.recoverAssets](#recoverassets11)替代。
3816
3817**系统接口**:此接口为系统接口。
3818
3819**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
3820
3821**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
3822
3823**参数:**
3824
3825| 参数名   | 类型                      | 必填 | 说明       |
3826| -------- | ------------------------- | ---- | ---------- |
3827| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | 是   | 回收站中待恢复图片或者视频数组。 |
3828
3829**返回值:**
3830
3831| 类型                                    | 说明              |
3832| --------------------------------------- | ----------------- |
3833|Promise&lt;void&gt; | Promise对象,返回void。 |
3834
3835**错误码:**
3836
3837接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
3838
3839| 错误码ID | 错误信息 |
3840| -------- | ---------------------------------------- |
3841| 202      |  Called by non-system application.         |
3842| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3843| 13900012     | Permission denied.         |
3844| 13900020     | Invalid argument.         |
3845| 14000011       | System inner fail.         |
3846
3847**示例:**
3848
3849```ts
3850import { dataSharePredicates } from '@kit.ArkData';
3851import { BusinessError } from '@kit.BasicServicesKit';
3852
3853async function example() {
3854  try {
3855    console.info('recoverAssetsDemoPromise');
3856    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3857    let fetchOption: photoAccessHelper.FetchOptions = {
3858      fetchColumns: [],
3859      predicates: predicates
3860    };
3861    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH);
3862    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
3863    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
3864    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3865    album.recoverAssets([asset]).then(() => {
3866      console.info('album recoverAssets successfully');
3867    }).catch((err: BusinessError) => {
3868      console.error(`album recoverAssets failed with error: ${err.code}, ${err.message}`);
3869    });
3870  } catch (err) {
3871    console.error(`recoverAssetsDemoPromise failed with error: ${err.code}, ${err.message}`);
3872  }
3873}
3874```
3875
3876### deleteAssets<sup>(deprecated)</sup>
3877
3878deleteAssets(assets: Array&lt;PhotoAsset&gt;, callback: AsyncCallback&lt;void&gt;): void
3879
3880从回收站中彻底删除图片或者视频,需要先在回收站中预置文件资源。该方法使用callback形式来返回结果。
3881
3882> **说明:**
3883>
3884> 从API version 10开始支持,从API version 11开始废弃。建议使用[MediaAlbumChangeRequest.deleteAssets](#deleteassets11)替代。
3885
3886**注意**:此操作不可逆,执行此操作后文件资源将彻底删除,请谨慎操作。
3887
3888**系统接口**:此接口为系统接口。
3889
3890**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
3891
3892**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
3893
3894**参数:**
3895
3896| 参数名   | 类型                      | 必填 | 说明       |
3897| -------- | ------------------------- | ---- | ---------- |
3898| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | 是   | 回收站中待彻底删除图片或者视频数组。 |
3899| callback | AsyncCallback&lt;void&gt; | 是   | callback返回void。 |
3900
3901**错误码:**
3902
3903接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
3904
3905| 错误码ID | 错误信息 |
3906| -------- | ---------------------------------------- |
3907| 202      |  Called by non-system application.         |
3908| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3909| 13900012     | Permission denied.         |
3910| 13900020     | Invalid argument.         |
3911| 14000011       | System inner fail.         |
3912
3913**示例:**
3914
3915```ts
3916import { dataSharePredicates } from '@kit.ArkData';
3917
3918async function example() {
3919  try {
3920    console.info('deleteAssetsDemoCallback');
3921    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3922    let fetchOption: photoAccessHelper.FetchOptions = {
3923      fetchColumns: [],
3924      predicates: predicates
3925    };
3926    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH);
3927    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
3928    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
3929    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
3930    album.deleteAssets([asset], (err) => {
3931      if (err === undefined) {
3932        console.info('album deleteAssets successfully');
3933      } else {
3934        console.error(`album deleteAssets failed with error: ${err.code}, ${err.message}`);
3935      }
3936    });
3937  } catch (err) {
3938    console.error(`deleteAssetsDemoCallback failed with error: ${err.code}, ${err.message}`);
3939  }
3940}
3941```
3942
3943### deleteAssets<sup>(deprecated)</sup>
3944
3945deleteAssets(assets: Array&lt;PhotoAsset&gt;): Promise&lt;void&gt;
3946
3947从回收站中彻底删除图片或者视频,需要先在回收站中预置文件资源。该方法使用Promise来返回结果。
3948
3949> **说明:**
3950>
3951> 从API version 10开始支持,从API version 11开始废弃。建议使用[MediaAlbumChangeRequest.deleteAssets](#deleteassets11)替代。
3952
3953**注意**:此操作不可逆,执行此操作后文件资源将彻底删除,请谨慎操作。
3954
3955**系统接口**:此接口为系统接口。
3956
3957**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
3958
3959**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
3960
3961**参数:**
3962
3963| 参数名   | 类型                      | 必填 | 说明       |
3964| -------- | ------------------------- | ---- | ---------- |
3965| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | 是   | 回收站中待彻底删除图片或者视频数组。 |
3966
3967**返回值:**
3968
3969| 类型                                    | 说明              |
3970| --------------------------------------- | ----------------- |
3971|Promise&lt;void&gt; | Promise对象,返回void。 |
3972
3973**错误码:**
3974
3975接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
3976
3977| 错误码ID | 错误信息 |
3978| -------- | ---------------------------------------- |
3979| 202      |  Called by non-system application.         |
3980| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
3981| 13900012     | Permission denied.         |
3982| 13900020     | Invalid argument.         |
3983| 14000011       | System inner fail.         |
3984
3985**示例:**
3986
3987```ts
3988import { dataSharePredicates } from '@kit.ArkData';
3989import { BusinessError } from '@kit.BasicServicesKit';
3990
3991async function example() {
3992  try {
3993    console.info('deleteAssetsDemoPromise');
3994    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
3995    let fetchOption: photoAccessHelper.FetchOptions = {
3996      fetchColumns: [],
3997      predicates: predicates
3998    };
3999    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH);
4000    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
4001    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
4002    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
4003    album.deleteAssets([asset]).then(() => {
4004      console.info('album deleteAssets successfully');
4005    }).catch((err: BusinessError) => {
4006      console.error(`album deleteAssets failed with error: ${err.code}, ${err.message}`);
4007    });
4008  } catch (err) {
4009    console.error(`deleteAssetsDemoPromise failed with error: ${err.code}, ${err.message}`);
4010  }
4011}
4012```
4013
4014### setCoverUri<sup>(deprecated)</sup>
4015
4016setCoverUri(uri: string, callback: AsyncCallback&lt;void&gt;): void
4017
4018设置相册封面,该方法使用callback形式来返回结果。
4019
4020> **说明:**
4021>
4022> 从API version 10开始支持,从API version 11开始废弃。建议使用[MediaAlbumChangeRequest.setCoverUri](#setcoveruri11)替代。
4023
4024**注意**:此接口只可修改用户相册封面,不允许修改系统相册封面。
4025
4026**系统接口**:此接口为系统接口。
4027
4028**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
4029
4030**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4031
4032**参数:**
4033
4034| 参数名   | 类型                      | 必填 | 说明       |
4035| -------- | ------------------------- | ---- | ---------- |
4036| uri | string | 是   | 待设置为相册封面文件的uri。 |
4037| callback | AsyncCallback&lt;void&gt; | 是   | callback返回void。 |
4038
4039**错误码:**
4040
4041接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
4042
4043| 错误码ID | 错误信息 |
4044| -------- | ---------------------------------------- |
4045| 202      |  Called by non-system application.         |
4046| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4047| 13900012     | Permission denied.         |
4048| 13900020     | Invalid argument.         |
4049| 14000011       | System inner fail.         |
4050
4051**示例:**
4052
4053```ts
4054import { dataSharePredicates } from '@kit.ArkData';
4055
4056async function example() {
4057  try {
4058    console.info('setCoverUriDemoCallback');
4059    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4060    let fetchOption: photoAccessHelper.FetchOptions = {
4061      fetchColumns: [],
4062      predicates: predicates
4063    };
4064    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
4065    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
4066    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
4067    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
4068    album.setCoverUri(asset.uri, (err) => {
4069      if (err === undefined) {
4070        console.info('album setCoverUri successfully');
4071      } else {
4072        console.error(`album setCoverUri failed with error: ${err.code}, ${err.message}`);
4073      }
4074    });
4075  } catch (err) {
4076    console.error(`setCoverUriDemoCallback failed with error: ${err.code}, ${err.message}`);
4077  }
4078}
4079```
4080
4081### setCoverUri<sup>(deprecated)</sup>
4082
4083setCoverUri(uri: string): Promise&lt;void&gt;
4084
4085设置相册封面,该方法使用Promise来返回结果。
4086
4087> **说明:**
4088>
4089> 从API version 10开始支持,从API version 11开始废弃。建议使用[MediaAlbumChangeRequest.setCoverUri](#setcoveruri11)替代。
4090
4091**注意**:此接口只可修改用户相册封面,不允许修改系统相册封面。
4092
4093**系统接口**:此接口为系统接口。
4094
4095**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
4096
4097**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4098
4099**参数:**
4100
4101| 参数名   | 类型                      | 必填 | 说明       |
4102| -------- | ------------------------- | ---- | ---------- |
4103| uri | string | 是   | 待设置为相册封面文件的uri。 |
4104
4105**返回值:**
4106
4107| 类型                                    | 说明              |
4108| --------------------------------------- | ----------------- |
4109|Promise&lt;void&gt; | Promise对象,返回void。 |
4110
4111**错误码:**
4112
4113接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
4114
4115| 错误码ID | 错误信息 |
4116| -------- | ---------------------------------------- |
4117| 202      |  Called by non-system application.         |
4118| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4119| 13900012     | Permission denied.         |
4120| 13900020     | Invalid argument.         |
4121| 14000011       | System inner fail.         |
4122**示例:**
4123
4124```ts
4125import { dataSharePredicates } from '@kit.ArkData';
4126import { BusinessError } from '@kit.BasicServicesKit';
4127
4128async function example() {
4129  try {
4130    console.info('setCoverUriDemoPromise');
4131    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4132    let fetchOption: photoAccessHelper.FetchOptions = {
4133      fetchColumns: [],
4134      predicates: predicates
4135    };
4136    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
4137    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
4138    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOption);
4139    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
4140    album.setCoverUri(asset.uri).then(() => {
4141      console.info('album setCoverUri successfully');
4142    }).catch((err: BusinessError) => {
4143      console.error(`album setCoverUri failed with error: ${err.code}, ${err.message}`);
4144    });
4145  } catch (err) {
4146    console.error(`setCoverUriDemoPromise failed with error: ${err.code}, ${err.message}`);
4147  }
4148}
4149```
4150
4151## MediaAssetEditData<sup>11+</sup>
4152
4153资产编辑数据。
4154
4155**系统接口**:此接口为系统接口。
4156
4157**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4158
4159### 属性
4160
4161| 名称           | 类型    | 可读   | 可写  | 说明   |
4162| ------------ | ------ | ---- | ---- | ------- |
4163| compatibleFormat | string | 是    | 是    | 编辑数据的格式。<br>**系统接口**:此接口为系统接口。    |
4164| formatVersion | string | 是    | 是   | 编辑数据格式的版本。<br>**系统接口**:此接口为系统接口。    |
4165| data | string | 是    | 是   | 编辑数据的内容。<br>**系统接口**:此接口为系统接口。    |
4166
4167### constructor<sup>11+</sup>
4168
4169constructor(compatibleFormat: string, formatVersion: string)
4170
4171构造函数。
4172
4173**系统接口**:此接口为系统接口。
4174
4175**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4176
4177**参数:**
4178
4179| 参数名   | 类型                      | 必填 | 说明       |
4180| -------- | ------------------------- | ---- | ---------- |
4181| compatibleFormat | string | 是   | 编辑数据的格式。 |
4182| formatVersion | string | 是   | 编辑数据格式的版本。 |
4183
4184**错误码:**
4185
4186接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
4187
4188| 错误码ID | 错误信息 |
4189| -------- | ---------------------------------------- |
4190| 202      |  Called by non-system application.         |
4191| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4192| 14000011       | System inner fail.          |
4193
4194**示例:**
4195
4196```ts
4197let assetEditData: photoAccessHelper.MediaAssetEditData = new photoAccessHelper.MediaAssetEditData('system', '1.0');
4198```
4199
4200## MediaAssetChangeRequest<sup>11+</sup>
4201
4202资产变更请求。
4203
4204**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4205
4206### createAssetRequest<sup>11+</sup>
4207
4208static createAssetRequest(context: Context, displayName: string, options?: PhotoCreateOptions): MediaAssetChangeRequest
4209
4210指定待创建的图片或者视频的文件名,创建资产变更请求。
4211
4212待创建的文件名参数规格为:
4213- 应包含有效文件主名和图片或视频扩展名。
4214- 文件名字符串长度为1~255。
4215- 文件主名中不允许出现的非法英文字符。<br>API18开始,非法字符包括: \ / : * ? " < > | <br>API10-17,非法字符包括:. .. \ / : * ? " ' ` < > | { } [ ]
4216
4217**系统接口**:此接口为系统接口。
4218
4219**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4220
4221**参数:**
4222
4223| 参数名  | 类型    | 必填 | 说明                       |
4224| ------- | ------- | ---- | -------------------------- |
4225| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | 是   | 传入Ability实例的Context。 |
4226| displayName  | string        | 是   | 待创建的图片或者视频文件名。              |
4227| options  | [PhotoCreateOptions](#photocreateoptions)        | 否   | 图片或视频的创建选项。              |
4228
4229**返回值:**
4230
4231| 类型                                    | 说明              |
4232| --------------------------------------- | ----------------- |
4233| [MediaAssetChangeRequest](#mediaassetchangerequest11) | 返回创建资产的变更请求。 |
4234
4235**错误码:**
4236
4237接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
4238
4239| 错误码ID | 错误信息 |
4240| -------- | ---------------------------------------- |
4241| 202   |  Called by non-system application.         |
4242| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4243| 14000001      | Invalid display name.         |
4244| 14000011       | System inner fail.         |
4245
4246**示例:**
4247
4248```ts
4249async function example() {
4250  console.info('createAssetRequestDemo');
4251  try {
4252    let testFileName: string = 'testFile' + Date.now() + '.jpg';
4253    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createAssetRequest(context, testFileName);
4254    // 需要确保fileUri对应的资源存在。
4255    let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
4256    assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, fileUri);
4257    await phAccessHelper.applyChanges(assetChangeRequest);
4258    console.info('apply createAssetRequest successfully');
4259  } catch (err) {
4260    console.error(`createAssetRequestDemo failed with error: ${err.code}, ${err.message}`);
4261  }
4262}
4263```
4264
4265### setFavorite<sup>11+</sup>
4266
4267setFavorite(favoriteState: boolean): void
4268
4269将文件设置为收藏文件。
4270
4271**系统接口**:此接口为系统接口。
4272
4273**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4274
4275**参数:**
4276
4277| 参数名        | 类型      | 必填   | 说明                                 |
4278| ---------- | ------- | ---- | ---------------------------------- |
4279| favoriteState | boolean | 是    | 是否设置为收藏文件, true:设置为收藏文件;false:取消收藏。 |
4280
4281**错误码:**
4282
4283接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
4284
4285| 错误码ID | 错误信息 |
4286| -------- | ---------------------------------------- |
4287| 202        |  Called by non-system application.         |
4288| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4289| 14000011       | System inner fail.         |
4290
4291**示例:**
4292
4293```ts
4294import { dataSharePredicates } from '@kit.ArkData';
4295import { BusinessError } from '@kit.BasicServicesKit';
4296
4297async function example() {
4298  console.info('setFavoriteDemo');
4299  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4300  let fetchOption: photoAccessHelper.FetchOptions = {
4301    fetchColumns: [],
4302    predicates: predicates
4303  };
4304  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4305  let asset = await fetchResult.getFirstObject();
4306  let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
4307  assetChangeRequest.setFavorite(true);
4308  phAccessHelper.applyChanges(assetChangeRequest).then(() => {
4309    console.info('apply setFavorite successfully');
4310  }).catch((err: BusinessError) => {
4311    console.error(`apply setFavorite failed with error: ${err.code}, ${err.message}`);
4312  });
4313}
4314```
4315
4316### setHidden<sup>11+</sup>
4317
4318setHidden(hiddenState: boolean): void
4319
4320将文件设置为隐藏文件。
4321
4322**系统接口**:此接口为系统接口。
4323
4324**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4325
4326**参数:**
4327
4328| 参数名        | 类型      | 必填   | 说明                                 |
4329| ---------- | ------- | ---- | ---------------------------------- |
4330| hiddenState | boolean  | 是    | 是否设置为隐藏文件,true:将文件资产放入隐藏相册;false:从隐藏相册中恢复。 |
4331
4332**错误码:**
4333
4334接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
4335
4336| 错误码ID | 错误信息 |
4337| -------- | ---------------------------------------- |
4338| 202        |  Called by non-system application.         |
4339| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4340| 14000011       | System inner fail.         |
4341
4342**示例:**
4343
4344```ts
4345import { dataSharePredicates } from '@kit.ArkData';
4346import { BusinessError } from '@kit.BasicServicesKit';
4347
4348async function example() {
4349  console.info('setHiddenDemo');
4350  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4351  let fetchOption: photoAccessHelper.FetchOptions = {
4352    fetchColumns: [],
4353    predicates: predicates
4354  };
4355  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4356  let asset = await fetchResult.getFirstObject();
4357  let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
4358  assetChangeRequest.setHidden(true);
4359  phAccessHelper.applyChanges(assetChangeRequest).then(() => {
4360    console.info('apply setHidden successfully');
4361  }).catch((err: BusinessError) => {
4362    console.error(`apply setHidden failed with error: ${err.code}, ${err.message}`);
4363  });
4364}
4365```
4366
4367### setUserComment<sup>11+</sup>
4368
4369setUserComment(userComment: string): void
4370
4371修改媒体资产的备注信息。
4372
4373**系统接口**:此接口为系统接口。
4374
4375**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4376
4377**参数:**
4378
4379| 参数名        | 类型      | 必填   | 说明                                 |
4380| ---------- | ------- | ---- | ---------------------------------- |
4381| userComment | string | 是   | 待修改的资产备注信息,备注信息最长为420字符。 |
4382
4383**错误码:**
4384
4385接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
4386
4387| 错误码ID | 错误信息 |
4388| -------- | ---------------------------------------- |
4389| 202        |  Called by non-system application.         |
4390| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4391| 14000011       | System inner fail.         |
4392
4393**示例:**
4394
4395```ts
4396import { dataSharePredicates } from '@kit.ArkData';
4397import { BusinessError } from '@kit.BasicServicesKit';
4398
4399async function example() {
4400  console.info('setUserCommentDemo');
4401  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4402  let fetchOption: photoAccessHelper.FetchOptions = {
4403    fetchColumns: [],
4404    predicates: predicates
4405  };
4406  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4407  let asset = await fetchResult.getFirstObject();
4408  let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
4409  let userComment: string = 'test_set_user_comment';
4410  assetChangeRequest.setUserComment(userComment);
4411  phAccessHelper.applyChanges(assetChangeRequest).then(() => {
4412    console.info('apply setUserComment successfully');
4413  }).catch((err: BusinessError) => {
4414    console.error(`apply setUserComment failed with error: ${err.code}, ${err.message}`);
4415  });
4416}
4417```
4418
4419### setEditData<sup>11+</sup>
4420
4421setEditData(editData: MediaAssetEditData): void
4422
4423保存资产的编辑数据。
4424
4425**系统接口**:此接口为系统接口。
4426
4427**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4428
4429**参数:**
4430
4431| 参数名        | 类型      | 必填   | 说明                                 |
4432| ---------- | ------- | ---- | ---------------------------------- |
4433| editData | [MediaAssetEditData](#mediaasseteditdata11) | 是   | 待保存的资产编辑数据。 |
4434
4435**错误码:**
4436
4437接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
4438
4439| 错误码ID | 错误信息 |
4440| -------- | ---------------------------------------- |
4441| 202        |  Called by non-system application.         |
4442| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4443| 14000011       | System inner fail.         |
4444
4445**示例:**
4446
4447```ts
4448import { dataSharePredicates } from '@kit.ArkData';
4449import { BusinessError } from '@kit.BasicServicesKit';
4450
4451async function example() {
4452  console.info('setEditDataDemo');
4453  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4454  let fetchOption: photoAccessHelper.FetchOptions = {
4455    fetchColumns: [],
4456    predicates: predicates
4457  };
4458  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4459  let asset = await fetchResult.getFirstObject();
4460  let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
4461
4462  let assetEditData: photoAccessHelper.MediaAssetEditData = new photoAccessHelper.MediaAssetEditData('system', '1.0');
4463  let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.jpg';
4464  assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, fileUri);
4465  assetEditData.data = '123456';
4466  assetChangeRequest.setEditData(assetEditData);
4467  phAccessHelper.applyChanges(assetChangeRequest).then(() => {
4468    console.info('apply setEditData successfully');
4469  }).catch((err: BusinessError) => {
4470    console.error(`apply setEditData failed with error: ${err.code}, ${err.message}`);
4471  });
4472}
4473```
4474
4475### addResource<sup>11+</sup>
4476
4477addResource(type: ResourceType, proxy: PhotoProxy): void
4478
4479通过PhotoProxy数据添加资源。
4480
4481**注意**:对于同一个资产变更请求,不支持在成功添加资源后,重复调用该接口。
4482
4483**系统接口**:此接口为系统接口,仅提供给相机应用使用。
4484
4485**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4486
4487**参数:**
4488
4489| 参数名  | 类型                              | 必填 | 说明                   |
4490| ------- |---------------------------------| ---- |----------------------|
4491| type | [ResourceType](#resourcetype11) | 是   | 待添加资源的类型。            |
4492| proxy | [PhotoProxy](#photoproxy11)     | 是   | 待添加资源的PhotoProxy 数据。 |
4493
4494**错误码:**
4495
4496接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
4497
4498| 错误码ID    | 错误信息                              |
4499|----------|-----------------------------------|
4500| 202      | Called by non-system application. |
4501| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4502| 14000011 | System inner fail.                |
4503| 14000016 | Operation Not Support.            |
4504
4505**示例:**
4506
4507```ts
4508class PhotoProxyImpl implements photoAccessHelper.PhotoProxy {
4509  // 应用实现PhotoProxy。
4510}
4511
4512async function example() {
4513  console.info('addResourceByPhotoProxyDemo');
4514  try {
4515    let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE;
4516    let extension: string = 'jpg';
4517    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = photoAccessHelper.MediaAssetChangeRequest.createAssetRequest(context, photoType, extension);
4518    let photoProxy: PhotoProxyImpl = new PhotoProxyImpl();
4519    assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, photoProxy);
4520    await phAccessHelper.applyChanges(assetChangeRequest);
4521    console.info('addResourceByPhotoProxy successfully');
4522  } catch (err) {
4523    console.error(`addResourceByPhotoProxyDemo failed with error: ${err.code}, ${err.message}`);
4524  }
4525}
4526```
4527
4528### setLocation<sup>11+</sup>
4529
4530setLocation(longitude: number, latitude: number): void
4531
4532设置文件的经纬度信息。
4533
4534**系统接口**:此接口为系统接口
4535
4536**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4537
4538**参数:**
4539
4540| 参数名  | 类型          | 必填 | 说明    |
4541| ------- |-------------| ---- |-------|
4542| longitude | number      | 是   | 经度。 |
4543| latitude | number | 是   | 纬度。   |
4544
4545**错误码:**
4546
4547接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
4548
4549| 错误码ID | 错误信息 |
4550| -------- | ---------------------------------------- |
4551| 202      | Called by non-system application. |
4552| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4553| 14000011 |  System inner fail.         |
4554
4555**示例:**
4556
4557```ts
4558import { dataSharePredicates } from '@kit.ArkData';
4559import { BusinessError } from '@kit.BasicServicesKit';
4560
4561async function example() {
4562  console.info('setLocationDemo');
4563  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4564  let fetchOption: photoAccessHelper.FetchOptions = {
4565    fetchColumns: [],
4566    predicates: predicates
4567  };
4568  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4569  let asset = await fetchResult.getFirstObject();
4570  let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
4571  assetChangeRequest.setLocation(120.52, 30.40);
4572  phAccessHelper.applyChanges(assetChangeRequest).then(() => {
4573    console.info('apply setLocation successfully');
4574  }).catch((err: BusinessError) => {
4575    console.error(`apply setLocation failed with error: ${err.code}, ${err.message}`);
4576  });
4577}
4578```
4579
4580### setCameraShotKey<sup>12+</sup>
4581
4582setCameraShotKey(cameraShotKey: string): void
4583
4584设置锁屏相机拍照或录像的标记字段。
4585
4586**系统接口**:此接口为系统接口。
4587
4588**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4589
4590**参数:**
4591
4592| 参数名        | 类型      | 必填   | 说明                                 |
4593| ---------- | ------- | ---- | ---------------------------------- |
4594| cameraShotKey | string | 是   | 锁屏相机拍照或录像的标记字段(仅开放给系统相机,其key值由系统相机定义)。 |
4595
4596**错误码:**
4597
4598接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
4599
4600| 错误码ID | 错误信息 |
4601| -------- | ---------------------------------------- |
4602| 202        |  Called by non-system application.         |
4603| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4604| 14000011       | System inner fail.         |
4605
4606**示例:**
4607
4608```ts
4609async function example(asset: photoAccessHelper.PhotoAsset) {
4610  console.info('setCameraShotKeyDemo');
4611  try {
4612    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
4613    let cameraShotKey: string = 'test_MediaAssetChangeRequest_setCameraShotKey';
4614    assetChangeRequest.setCameraShotKey(cameraShotKey);
4615    await phAccessHelper.applyChanges(assetChangeRequest);
4616    console.info('apply setCameraShotKey successfully');
4617  } catch (err) {
4618    console.error(`apply setCameraShotKey failed with error: ${err.code}, ${err.message}`);
4619  }
4620}
4621```
4622
4623### setEffectMode<sup>12+</sup>
4624
4625setEffectMode(mode: MovingPhotoEffectMode): void
4626
4627设置动态照片的效果模式。
4628
4629**系统接口**:此接口为系统接口。
4630
4631**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4632
4633**参数:**
4634
4635| 参数名        | 类型      | 必填   | 说明                                 |
4636| ---------- | ------- | ---- | ---------------------------------- |
4637| mode | [MovingPhotoEffectMode](#movingphotoeffectmode12) | 是   | 动态照片效果模式。 |
4638
4639**错误码:**
4640
4641接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
4642
4643| 错误码ID | 错误信息 |
4644| -------- | ---------------------------------------- |
4645| 202        |  Called by non-system application.         |
4646| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4647| 14000011       | System inner fail.         |
4648| 14000016       | Operation Not Support.         |
4649
4650**示例:**
4651
4652```ts
4653async function example(asset: photoAccessHelper.PhotoAsset) {
4654  console.info('setEffectModeDemo');
4655  try {
4656    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
4657    assetChangeRequest.setEffectMode(photoAccessHelper.MovingPhotoEffectMode.LONG_EXPOSURE);
4658    // 需要确保fileUri对应的资源存在。
4659    let imageFileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/long_exposure.jpg';
4660    let videoFileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/long_exposure.mp4';
4661    assetChangeRequest.addResource(photoAccessHelper.ResourceType.IMAGE_RESOURCE, imageFileUri);
4662    assetChangeRequest.addResource(photoAccessHelper.ResourceType.VIDEO_RESOURCE, videoFileUri);
4663    await phAccessHelper.applyChanges(assetChangeRequest);
4664    console.info('apply setEffectMode successfully');
4665  } catch (err) {
4666    console.error(`apply setEffectMode failed with error: ${err.code}, ${err.message}`);
4667  }
4668}
4669```
4670
4671### setSupportedWatermarkType<sup>14+</sup>
4672
4673setSupportedWatermarkType(watermarkType: WatermarkType): void
4674
4675设置拍照照片支持的水印类型。
4676
4677**系统接口**:此接口为系统接口。
4678
4679**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4680
4681**参数:**
4682
4683| 参数名        | 类型      | 必填   | 说明                                 |
4684| ---------- | ------- | ---- | ---------------------------------- |
4685| watermarkType | [WatermarkType](#watermarktype14) | 是   | 水印可编辑标识。 |
4686
4687**错误码:**
4688
4689接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
4690
4691| 错误码ID | 错误信息 |
4692| -------- | ---------------------------------------- |
4693| 202        |  Called by non-system application.         |
4694| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4695| 14000011       | Internal system error.         |
4696
4697**示例:**
4698
4699```ts
4700import { dataSharePredicates } from '@kit.ArkData';
4701import { photoAccessHelper } from '@kit.MediaLibraryKit';
4702import { common } from '@kit.AbilityKit';
4703
4704// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
4705let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
4706let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
4707
4708async function example() {
4709  console.info('setSupportedWatermarkTypeDemo');
4710  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4711  let fetchOption: photoAccessHelper.FetchOptions = {
4712    fetchColumns: [],
4713    predicates: predicates
4714  };
4715  try {
4716    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4717    let asset = await fetchResult.getFirstObject();
4718    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
4719    assetChangeRequest.setSupportedWatermarkType(photoAccessHelper.WatermarkType.BRAND_COMMON);
4720    await phAccessHelper.applyChanges(assetChangeRequest);
4721    console.info('apply setSupportedWatermarkType successfully');
4722  } catch (err) {
4723    console.error(`apply setSupportedWatermarkType failed with error: ${err.code}, ${err.message}`);
4724  }
4725}
4726```
4727
4728### deleteLocalAssetsPermanently<sup>18+</sup>
4729
4730static deleteLocalAssetsPermanently(context: Context, assets: Array\<PhotoAsset>): Promise&lt;void&gt;
4731
4732批量彻底删除照片或者视频,使用promise方式返回异步结果。
4733
4734**注意**:此操作不可逆,执行此操作后文件资源将彻底删除,请谨慎操作。
4735
4736**系统接口**:此接口为系统接口。
4737
4738**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4739
4740**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
4741
4742**参数:**
4743
4744| 参数名  | 类型             | 必填   | 说明    |
4745| ---- | -------------- | ---- | ----- |
4746| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | 是    | 传入Ability实例的Context。 |
4747| assets | Array\<[PhotoAsset](#photoasset)>| 是    | 待彻底删除的图片或者视频数组。 |
4748
4749**返回值:**
4750
4751| 类型                  | 说明         |
4752| ------------------- | ---------- |
4753| Promise&lt;void&gt; | Promise对象,返回void。 |
4754
4755**错误码:**
4756
4757接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
4758
4759| 错误码ID | 错误信息 |
4760| -------- | ---------------------------------------- |
4761| 201   | Permission denied.       |
4762| 202   | Called by non-system application.       |
4763| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4764| 14000011   | Internal system error.
4765
4766**示例:**
4767
4768```ts
4769import { dataSharePredicates } from '@kit.ArkData';
4770import { BusinessError } from '@kit.BasicServicesKit';
4771import { common } from '@kit.AbilityKit';
4772
4773struct Index {
4774  // 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
4775  public context = this.getUIContext().getHostContext() as common.UIAbilityContext;
4776  public phAccessHelper = photoAccessHelper.getPhotoAccessHelper(this.context);
4777
4778  async function example() {
4779    console.info('deleteAssetsPermanentlyDemo');
4780    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4781    let fetchOptions: photoAccessHelper.FetchOptions = {
4782      fetchColumns: [],
4783      predicates: predicates
4784    };
4785    try {
4786      let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await this.phAccessHelper.getAssets(fetchOptions);
4787      let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects();
4788      await photoAccessHelper.MediaAssetChangeRequest.deleteLocalAssetsPermanently(this.context, photoAssetList);
4789    } catch (err) {
4790      console.error(`deleteAssetsPermanentlyDemo failed with error: ${err.code}, ${err.message}`);
4791    }
4792  }
4793}
4794```
4795
4796### setDisplayName<sup>18+</sup>
4797
4798setDisplayName(displayName: string): void
4799
4800修改媒体资产的文件名(含扩展名)。
4801
4802**系统接口**:此接口为系统接口。
4803
4804**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4805
4806**参数:**
4807
4808| 参数名        | 类型      | 必填   | 说明                                 |
4809| ---------- | ------- | ---- | ---------------------------------- |
4810| displayName | string | 是   | 待修改的资产文件名(含扩展名)。<br>参数规格:<br>- 需要包含扩展名。<br>- 文件名(不含扩展名)的字符串长度为1~255。<br>- 文件名中不允许出现非法字符,如:\ / : * ? " < > \| |
4811
4812**错误码:**
4813
4814接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
4815
4816| 错误码ID | 错误信息 |
4817| -------- | ---------------------------------------- |
4818| 202        |  Called by non-system application.         |
4819| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4820| 14000011       | Internal system error.         |
4821
4822**示例:**
4823
4824```ts
4825import { dataSharePredicates } from '@kit.ArkData';
4826import { photoAccessHelper } from '@kit.MediaLibraryKit';
4827import { common } from '@kit.AbilityKit';
4828
4829// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
4830let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
4831let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
4832
4833async function example() {
4834  console.info('setDisplayNameDemo');
4835  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4836  let fetchOption: photoAccessHelper.FetchOptions = {
4837    fetchColumns: [],
4838    predicates: predicates
4839  };
4840  try {
4841    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4842    let asset = await fetchResult.getFirstObject();
4843    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
4844    let newDisplayName: string = 'newDisplayName.jpg';
4845    assetChangeRequest.setDisplayName(newDisplayName);
4846    await phAccessHelper.applyChanges(assetChangeRequest);
4847    console.info('apply setDisplayName successfully');
4848  } catch (err) {
4849    console.error(`apply setDisplayName failed with error: ${err.code}, ${err.message}`);
4850  }
4851}
4852```
4853
4854## MediaAssetsChangeRequest<sup>11+</sup>
4855
4856批量资产变更请求。
4857
4858**系统接口**:此接口为系统接口。
4859
4860**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4861
4862### constructor<sup>11+</sup>
4863
4864constructor(assets: Array&lt;PhotoAsset&gt;)
4865
4866构造函数。
4867
4868**系统接口**:此接口为系统接口。
4869
4870**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4871
4872**参数:**
4873
4874| 参数名   | 类型                      | 必填 | 说明       |
4875| -------- | ------------------------- | ---- | ---------- |
4876| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | 是   | 需要变更的资产数组。 |
4877
4878**错误码:**
4879
4880接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
4881
4882| 错误码ID | 错误信息 |
4883| -------- | ---------------------------------------- |
4884| 202        |  Called by non-system application.   |
4885| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4886| 14000011       | System inner fail.          |
4887
4888**示例:**
4889
4890```ts
4891import { dataSharePredicates } from '@kit.ArkData';
4892
4893async function example() {
4894  console.info('MediaAssetsChangeRequest constructorDemo');
4895  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4896  let fetchOption: photoAccessHelper.FetchOptions = {
4897    fetchColumns: [],
4898    predicates: predicates
4899  };
4900  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4901  let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects();
4902  let assetsChangeRequest: photoAccessHelper.MediaAssetsChangeRequest = new photoAccessHelper.MediaAssetsChangeRequest(photoAssetList);
4903}
4904```
4905
4906### setFavorite<sup>11+</sup>
4907
4908setFavorite(favoriteState: boolean): void
4909
4910将文件设置为收藏文件。
4911
4912**系统接口**:此接口为系统接口。
4913
4914**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4915
4916**参数:**
4917
4918| 参数名        | 类型      | 必填   | 说明                                 |
4919| ---------- | ------- | ---- | ---------------------------------- |
4920| favoriteState | boolean | 是    | 是否设置为收藏文件, true:设置为收藏文件;false:取消收藏。 |
4921
4922**错误码:**
4923
4924接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
4925
4926| 错误码ID | 错误信息 |
4927| -------- | ---------------------------------------- |
4928| 202        |  Called by non-system application.         |
4929| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4930| 14000011       | System inner fail.         |
4931
4932**示例:**
4933
4934```ts
4935import { dataSharePredicates } from '@kit.ArkData';
4936import { BusinessError } from '@kit.BasicServicesKit';
4937
4938async function example() {
4939  console.info('setFavoriteDemo');
4940  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4941  let fetchOption: photoAccessHelper.FetchOptions = {
4942    fetchColumns: [],
4943    predicates: predicates
4944  };
4945  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4946  let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects();
4947  let assetsChangeRequest: photoAccessHelper.MediaAssetsChangeRequest = new photoAccessHelper.MediaAssetsChangeRequest(photoAssetList);
4948  assetsChangeRequest.setFavorite(true);
4949  phAccessHelper.applyChanges(assetsChangeRequest).then(() => {
4950    console.info('apply setFavorite successfully');
4951  }).catch((err: BusinessError) => {
4952    console.error(`apply setFavorite failed with error: ${err.code}, ${err.message}`);
4953  });
4954}
4955```
4956
4957### setHidden<sup>11+</sup>
4958
4959setHidden(hiddenState: boolean): void
4960
4961将文件设置为隐藏文件。
4962
4963**系统接口**:此接口为系统接口。
4964
4965**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
4966
4967**参数:**
4968
4969| 参数名        | 类型      | 必填   | 说明                                 |
4970| ---------- | ------- | ---- | ---------------------------------- |
4971| hiddenState | boolean  | 是    | 是否设置为隐藏文件,true:将文件资产放入隐藏相册;false:从隐藏相册中恢复。 |
4972
4973**错误码:**
4974
4975接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
4976
4977| 错误码ID | 错误信息 |
4978| -------- | ---------------------------------------- |
4979| 202        |  Called by non-system application.         |
4980| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
4981| 14000011       | System inner fail.         |
4982
4983**示例:**
4984
4985```ts
4986import { dataSharePredicates } from '@kit.ArkData';
4987import { BusinessError } from '@kit.BasicServicesKit';
4988
4989async function example() {
4990  console.info('setHiddenDemo');
4991  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
4992  let fetchOption: photoAccessHelper.FetchOptions = {
4993    fetchColumns: [],
4994    predicates: predicates
4995  };
4996  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
4997  let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects();
4998  let assetsChangeRequest: photoAccessHelper.MediaAssetsChangeRequest = new photoAccessHelper.MediaAssetsChangeRequest(photoAssetList);
4999  assetsChangeRequest.setHidden(true);
5000  phAccessHelper.applyChanges(assetsChangeRequest).then(() => {
5001    console.info('apply setHidden successfully');
5002  }).catch((err: BusinessError) => {
5003    console.error(`apply setHidden failed with error: ${err.code}, ${err.message}`);
5004  });
5005}
5006```
5007
5008### setUserComment<sup>11+</sup>
5009
5010setUserComment(userComment: string): void
5011
5012修改媒体资产的备注信息。
5013
5014**系统接口**:此接口为系统接口。
5015
5016**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5017
5018**参数:**
5019
5020| 参数名        | 类型      | 必填   | 说明                                 |
5021| ---------- | ------- | ---- | ---------------------------------- |
5022| userComment | string | 是   | 待修改的资产备注信息,备注信息最长为420字符。 |
5023
5024**错误码:**
5025
5026接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
5027
5028| 错误码ID | 错误信息 |
5029| -------- | ---------------------------------------- |
5030| 202        |  Called by non-system application.         |
5031| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
5032| 14000011       | System inner fail.         |
5033
5034**示例:**
5035
5036```ts
5037import { dataSharePredicates } from '@kit.ArkData';
5038import { BusinessError } from '@kit.BasicServicesKit';
5039
5040async function example() {
5041  console.info('setUserCommentDemo');
5042  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5043  let fetchOption: photoAccessHelper.FetchOptions = {
5044    fetchColumns: [],
5045    predicates: predicates
5046  };
5047  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
5048  let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects();
5049  let assetsChangeRequest: photoAccessHelper.MediaAssetsChangeRequest = new photoAccessHelper.MediaAssetsChangeRequest(photoAssetList);
5050  assetsChangeRequest.setUserComment('test_set_user_comment');
5051  phAccessHelper.applyChanges(assetsChangeRequest).then(() => {
5052    console.info('apply setUserComment successfully');
5053  }).catch((err: BusinessError) => {
5054    console.error(`apply setUserComment failed with error: ${err.code}, ${err.message}`);
5055  });
5056}
5057```
5058
5059### setIsRecentShow<sup>18+</sup>
5060
5061setIsRecentShow(isRencentShow: boolean): void
5062
5063设置当前资产是否在“最近”列表中显示。
5064
5065**系统接口**:此接口为系统接口。
5066
5067**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5068
5069**参数:**
5070
5071| 参数名        | 类型      | 必填   | 说明                                 |
5072| ---------- | ------- | ---- | ---------------------------------- |
5073| isRencentShow | boolean | 是   | 表示当前资产是否在“最近”列表中显示。true表示显示,false表示不显示。 |
5074
5075**错误码:**
5076
5077接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
5078
5079| 错误码ID | 错误信息 |
5080| -------- | ---------------------------------------- |
5081| 202        |  Called by non-system application.         |
5082| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
5083| 14000011       | System inner fail.         |
5084
5085**示例:**
5086
5087```ts
5088import { dataSharePredicates } from '@kit.ArkData';
5089import { BusinessError } from '@kit.BasicServicesKit';
5090
5091async function example() {
5092  console.info('setIsRecentShowDemo');
5093  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5094  let fetchOption: photoAccessHelper.FetchOptions = {
5095    fetchColumns: [],
5096    predicates: predicates
5097  };
5098  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOption);
5099  let photoAssetList: Array<photoAccessHelper.PhotoAsset> = await fetchResult.getAllObjects();
5100  let assetsChangeRequest: photoAccessHelper.MediaAssetsChangeRequest = new photoAccessHelper.MediaAssetsChangeRequest(photoAssetList);
5101  assetsChangeRequest.setIsRecentShow(true);
5102  phAccessHelper.applyChanges(assetsChangeRequest).then(() => {
5103    console.info('apply setIsRecentShow successfully');
5104  }).catch((err: BusinessError) => {
5105    console.error(`apply setIsRecentShow failed with error: ${err.code}, ${err.message}`);
5106  });
5107}
5108```
5109
5110## MediaAlbumChangeRequest<sup>11+</sup>
5111
5112相册变更请求。
5113
5114**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5115
5116### createAlbumRequest<sup>11+</sup>
5117
5118static createAlbumRequest(context: Context, name: string): MediaAlbumChangeRequest
5119
5120创建相册变更请求。
5121
5122相册名的参数规格为:
5123- 相册名字符串长度为1~255。
5124- 不允许出现非法字符,包括:<br> . .. \ / : * ? " ' ` < > | { } [ ]
5125- 英文字符大小写不敏感。
5126- 相册名不允许重名。
5127
5128**系统接口**:此接口为系统接口。
5129
5130**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5131
5132**参数:**
5133
5134| 参数名  | 类型    | 必填 | 说明                       |
5135| ------- | ------- | ---- | -------------------------- |
5136| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | 是   | 传入Ability实例的Context。 |
5137| name | string | 是   | 待创建相册的名称。|
5138
5139**返回值:**
5140
5141| 类型                                    | 说明              |
5142| --------------------------------------- | ----------------- |
5143| [MediaAlbumChangeRequest](#mediaalbumchangerequest11) | 返回创建相册的变更请求。 |
5144
5145**错误码:**
5146
5147接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
5148
5149| 错误码ID | 错误信息 |
5150| -------- | ---------------------------------------- |
5151| 202   |  Called by non-system application.         |
5152| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
5153| 14000011   | System inner fail.        |
5154
5155**示例:**
5156
5157```ts
5158async function example() {
5159  console.info('createAlbumRequestDemo');
5160  try {
5161    let albumName: string = 'newAlbumName' + new Date().getTime();
5162    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = photoAccessHelper.MediaAlbumChangeRequest.createAlbumRequest(context, albumName);
5163    await phAccessHelper.applyChanges(albumChangeRequest);
5164    console.info('apply createAlbumRequest successfully');
5165  } catch (err) {
5166    console.error(`createAlbumRequestDemo failed with error: ${err.code}, ${err.message}`);
5167  }
5168}
5169```
5170
5171### deleteAlbums<sup>11+</sup>
5172
5173static deleteAlbums(context: Context, albums: Array&lt;Album&gt;): Promise&lt;void&gt;
5174
5175删除相册,使用Promise方式返回结果。
5176
5177删除相册前需先确保相册存在,只能删除用户相册。
5178
5179**系统接口**:此接口为系统接口。
5180
5181**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
5182
5183**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5184
5185**参数:**
5186
5187| 参数名  | 类型    | 必填 | 说明                       |
5188| ------- | ------- | ---- | -------------------------- |
5189| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | 是   | 传入Ability实例的Context。 |
5190| albums  |  Array&lt;[Album](#album)&gt;          | 是   | 待删除的相册数组。         |
5191
5192**返回值:**
5193
5194| 类型                                    | 说明              |
5195| --------------------------------------- | ----------------- |
5196| Promise&lt;void&gt;| Promise对象,返回void。 |
5197
5198**错误码:**
5199
5200接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
5201
5202| 错误码ID | 错误信息 |
5203| -------- | ---------------------------------------- |
5204| 201      |  Permission denied.         |
5205| 202   |  Called by non-system application.  |
5206| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
5207| 14000011 |  System inner fail.         |
5208
5209**示例:**
5210
5211```ts
5212import { dataSharePredicates } from '@kit.ArkData';
5213
5214async function example() {
5215  console.info('deleteAlbumsDemo');
5216  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5217  let fetchOptions: photoAccessHelper.FetchOptions = {
5218    fetchColumns: [],
5219    predicates: predicates
5220  };
5221  try {
5222    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions);
5223    let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
5224    await photoAccessHelper.MediaAlbumChangeRequest.deleteAlbums(context, [album]);
5225    console.info('deleteAlbums successfully');
5226  } catch (err) {
5227    console.error(`deleteAlbumsDemo failed with error: ${err.code}, ${err.message}`);
5228  }
5229}
5230```
5231
5232### setCoverUri<sup>11+</sup>
5233
5234setCoverUri(coverUri: string): void
5235
5236设置相册封面。
5237
5238**系统接口**:此接口为系统接口。
5239
5240**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5241
5242**参数:**
5243
5244| 参数名        | 类型      | 必填   | 说明                                 |
5245| ---------- | ------- | ---- | ---------------------------------- |
5246| coverUri | string | 是   | 待设置为相册封面文件的uri。 |
5247
5248**错误码:**
5249
5250接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
5251
5252| 错误码ID | 错误信息 |
5253| -------- | ---------------------------------------- |
5254| 202        |  Called by non-system application.         |
5255| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
5256| 14000011       | System inner fail.         |
5257
5258**示例:**
5259
5260```ts
5261import { dataSharePredicates } from '@kit.ArkData';
5262
5263async function example() {
5264  console.info('setCoverUriDemo');
5265  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5266  let fetchOptions: photoAccessHelper.FetchOptions = {
5267    fetchColumns: [],
5268    predicates: predicates
5269  };
5270  try {
5271    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
5272    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
5273    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions);
5274    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
5275
5276    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
5277    albumChangeRequest.setCoverUri(asset.uri);
5278    await phAccessHelper.applyChanges(albumChangeRequest);
5279    console.info('setCoverUri successfully');
5280  } catch (err) {
5281    console.error(`setCoverUriDemo failed with error: ${err.code}, ${err.message}`);
5282  }
5283}
5284```
5285
5286### moveAssets<sup>11+</sup>
5287
5288moveAssets(assets: Array&lt;PhotoAsset&gt;, targetAlbum: Album): void
5289
5290从相册中移动资产到另一个目标相册。
5291
5292**系统接口**:此接口为系统接口。
5293
5294**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5295
5296**参数:**
5297
5298| 参数名        | 类型      | 必填   | 说明                                 |
5299| ---------- | ------- | ---- | ---------------------------------- |
5300| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | 是   | 待从相册中移出的资产数组。 |
5301| targetAlbum | Album | 是   | 待移入资产的目标相册。 |
5302
5303**错误码:**
5304
5305接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
5306
5307| 错误码ID | 错误信息 |
5308| -------- | ---------------------------------------- |
5309| 202      |  Called by non-system application.         |
5310| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
5311| 14000011       | System inner fail.         |
5312| 14000016 |  Operation Not Support.     |
5313
5314**示例:**
5315
5316```ts
5317import { dataSharePredicates } from '@kit.ArkData';
5318
5319async function example() {
5320  console.info('moveAssetsDemo');
5321  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5322  let fetchOptions: photoAccessHelper.FetchOptions = {
5323    fetchColumns: [],
5324    predicates: predicates
5325  };
5326  try {
5327    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
5328    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
5329    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions);
5330    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
5331
5332    if (albumFetchResult.isAfterLast()) {
5333      console.error('lack of album to be moved into');
5334      return;
5335    }
5336    let nextAlbum: photoAccessHelper.Album = await albumFetchResult.getNextObject();
5337    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
5338    albumChangeRequest.moveAssets([asset], nextAlbum);
5339    await phAccessHelper.applyChanges(albumChangeRequest);
5340    console.info('moveAssets successfully');
5341  } catch (err) {
5342    console.error(`moveAssetsDemo failed with error: ${err.code}, ${err.message}`);
5343  }
5344}
5345```
5346
5347### recoverAssets<sup>11+</sup>
5348
5349recoverAssets(assets: Array&lt;PhotoAsset&gt;): void
5350
5351从回收站中恢复资产。
5352
5353**系统接口**:此接口为系统接口。
5354
5355**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5356
5357**参数:**
5358
5359| 参数名        | 类型      | 必填   | 说明                                 |
5360| ---------- | ------- | ---- | ---------------------------------- |
5361| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | 是   | 待从回收站中恢复的资产数组。 |
5362
5363**错误码:**
5364
5365接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
5366
5367| 错误码ID | 错误信息 |
5368| -------- | ---------------------------------------- |
5369| 202      |  Called by non-system application.         |
5370| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
5371| 14000011       | System inner fail.         |
5372| 14000016 |  Operation Not Support.     |
5373
5374**示例:**
5375
5376```ts
5377import { dataSharePredicates } from '@kit.ArkData';
5378
5379async function example() {
5380  console.info('recoverAssetsDemo');
5381  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5382  let fetchOptions: photoAccessHelper.FetchOptions = {
5383    fetchColumns: [],
5384    predicates: predicates
5385  };
5386  try {
5387    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH);
5388    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
5389    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions);
5390    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
5391
5392    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
5393    albumChangeRequest.recoverAssets([asset]);
5394    await phAccessHelper.applyChanges(albumChangeRequest);
5395    console.info('recoverAssets successfully');
5396  } catch (err) {
5397    console.error(`recoverAssetsDemo failed with error: ${err.code}, ${err.message}`);
5398  }
5399}
5400```
5401
5402### deleteAssets<sup>11+</sup>
5403
5404deleteAssets(assets: Array&lt;PhotoAsset&gt;): void
5405
5406从回收站中彻底删除资产。
5407
5408**注意**:此操作不可逆,执行此操作后文件资源将彻底删除,请谨慎操作。
5409
5410**系统接口**:此接口为系统接口。
5411
5412**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5413
5414**参数:**
5415
5416| 参数名        | 类型      | 必填   | 说明                                 |
5417| ---------- | ------- | ---- | ---------------------------------- |
5418| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | 是   | 待从回收站中彻底删除的资产数组。 |
5419
5420**错误码:**
5421
5422接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
5423
5424| 错误码ID | 错误信息 |
5425| -------- | ---------------------------------------- |
5426| 202      |  Called by non-system application.         |
5427| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
5428| 14000011       | System inner fail.         |
5429| 14000016 |  Operation Not Support.     |
5430
5431**示例:**
5432
5433```ts
5434import { dataSharePredicates } from '@kit.ArkData';
5435
5436async function example() {
5437  console.info('deleteAssetsPermanentlyDemo');
5438  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5439  let fetchOptions: photoAccessHelper.FetchOptions = {
5440    fetchColumns: [],
5441    predicates: predicates
5442  };
5443  try {
5444    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH);
5445    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
5446    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await album.getAssets(fetchOptions);
5447    let asset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
5448
5449    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
5450    albumChangeRequest.deleteAssets([asset]);
5451    await phAccessHelper.applyChanges(albumChangeRequest);
5452    console.info('succeed to deleteAssets permanently');
5453  } catch (err) {
5454    console.error(`deleteAssetsPermanentlyDemo failed with error: ${err.code}, ${err.message}`);
5455  }
5456}
5457```
5458
5459### setDisplayLevel<sup>11+</sup>
5460
5461setDisplayLevel(displayLevel: number): void
5462
5463设置人像相册的显示级别。
5464
5465**系统接口**:此接口为系统接口。
5466
5467**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5468
5469**参数:**
5470
5471| 参数名        | 类型      | 必填   | 说明                                 |
5472| ---------- | ------- | ---- | ---------------------------------- |
5473| displayLevel | number | 是    | 设置人像相册的显示级别, 0:取消该人像相册收藏;1:设置人像相册为首届面;2:设置人像相册为更多界面;3:设置人像相册为收藏界面。 |
5474
5475**错误码:**
5476
5477接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
5478
5479| 错误码ID | 错误信息 |
5480| -------- | ---------------------------------------- |
5481| 202        |  Called by non-system application.         |
5482| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
5483| 14000011       | System inner fail.         |
5484
5485**示例:**
5486
5487``` ts
5488import { dataSharePredicates } from '@kit.ArkData';
5489
5490async function example() {
5491  try {
5492    console.info('setDisplayLevel Example')
5493    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5494    predicates.equalTo('user_display_level', 2);
5495    let fetchOptions: photoAccessHelper.FetchOptions = {
5496      fetchColumns: [],
5497      predicates: predicates
5498    };
5499    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.PORTRAIT, fetchOptions);
5500    let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
5501    let changeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
5502    changeRequest.setDisplayLevel(1);
5503    await phAccessHelper.applyChanges(changeRequest);
5504  } catch (err) {
5505    console.error(`setDisplayLevel failed with error: ${err.code}, ${err.message}`);
5506  }
5507}
5508```
5509
5510### setIsMe<sup>11+</sup>
5511
5512setIsMe(): void
5513
5514将人像相册的人物关系设置为“我”。
5515
5516**系统接口**:此接口为系统接口。
5517
5518**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5519
5520**错误码:**
5521
5522接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
5523
5524| 错误码ID | 错误信息 |
5525| -------- | ---------------------------------------- |
5526| 202        |  Called by non-system application.         |
5527| 401    | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5528| 14000011       | System inner fail.         |
5529
5530**示例:**
5531
5532``` ts
5533import { dataSharePredicates } from '@kit.ArkData';
5534
5535async function example() {
5536  try {
5537    console.info('setIsMe Example')
5538    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5539    predicates.equalTo('user_display_level', 2);
5540    let fetchOptions: photoAccessHelper.FetchOptions = {
5541      fetchColumns: [],
5542      predicates: predicates
5543    };
5544    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.PORTRAIT, fetchOptions);
5545    let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
5546    let changeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
5547    changeRequest.setIsMe();
5548    await phAccessHelper.applyChanges(changeRequest);
5549  } catch (err) {
5550    console.error(`setIsMe failed with error: ${err.code}, ${err.message}`);
5551  }
5552}
5553```
5554
5555### dismissAssets<sup>11+</sup>
5556
5557dismissAssets(assets: Array&lt;PhotoAsset&gt;): void
5558
5559从该人像相册或合影相册中移除指定图片。
5560
5561**系统接口**:此接口为系统接口。
5562
5563**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5564
5565**参数:**
5566
5567| 参数名        | 类型      | 必填   | 说明                                 |
5568| ---------- | ------- | ---- | ---------------------------------- |
5569| assets | Array&lt;PhotoAsset&gt; | 是    | 需要移除的文件列表。 |
5570
5571**错误码:**
5572
5573接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
5574
5575| 错误码ID | 错误信息 |
5576| -------- | ---------------------------------------- |
5577| 202        |  Called by non-system application.         |
5578| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
5579| 14000011       | System inner fail.         |
5580| 14000016       | Operation Not support.         |
5581
5582**示例:**
5583
5584``` ts
5585import { dataSharePredicates } from '@kit.ArkData';
5586
5587async function example() {
5588  try {
5589    console.info('dismissAssets Example')
5590    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5591    predicates.equalTo('user_display_level', 2);
5592    let fetchOptions: photoAccessHelper.FetchOptions = {
5593      fetchColumns: [],
5594      predicates: predicates
5595    };
5596    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.PORTRAIT, fetchOptions);
5597    let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
5598
5599    let predicatesAsset: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5600    let assetFetchOptions: photoAccessHelper.FetchOptions = {
5601      fetchColumns: [],
5602      predicates: predicatesAsset
5603    };
5604    let assetFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(assetFetchOptions);
5605    let asset: photoAccessHelper.PhotoAsset = await assetFetchResult.getFirstObject();
5606
5607    let changeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
5608    changeRequest.dismissAssets([asset]);
5609    await phAccessHelper.applyChanges(changeRequest);
5610  } catch (err) {
5611    console.error(`dismissAssets failed with error: ${err.code}, ${err.message}`);
5612  }
5613}
5614```
5615
5616### mergeAlbum<sup>11+</sup>
5617
5618mergeAlbum(target: Album): void
5619
5620将两个人像相册合并。
5621
5622**系统接口**:此接口为系统接口。
5623
5624**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5625
5626**参数:**
5627
5628| 参数名        | 类型      | 必填   | 说明                                 |
5629| ---------- | ------- | ---- | ---------------------------------- |
5630| target | [Album](#album) | 是    | 需要合并的目标相册,合并相册必须重命名。 |
5631
5632**错误码:**
5633
5634接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
5635
5636| 错误码ID | 错误信息 |
5637| -------- | ---------------------------------------- |
5638| 202        |  Called by non-system application.         |
5639| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
5640| 14000011       | System inner fail.         |
5641| 14000016       | Operation Not support.         |
5642
5643**示例:**
5644
5645``` ts
5646import { dataSharePredicates } from '@kit.ArkData';
5647
5648async function example() {
5649  try {
5650    console.info('mergeAlbum Example')
5651    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5652    predicates.equalTo('user_display_level', 2);
5653    let fetchOptions: photoAccessHelper.FetchOptions = {
5654      fetchColumns: [],
5655      predicates: predicates
5656    };
5657    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.PORTRAIT, fetchOptions);
5658    let album: photoAccessHelper.Album = await fetchResult.getFirstObject();
5659    if (fetchResult.isAfterLast()) {
5660      console.error('lack of album to merge');
5661      return;
5662    }
5663    let target: photoAccessHelper.Album = await fetchResult.getNextObject();
5664
5665    let changeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
5666    changeRequest.mergeAlbum(target);
5667    changeRequest.setAlbumName("testName");
5668    await phAccessHelper.applyChanges(changeRequest);
5669  } catch (err) {
5670    console.error(`mergeAlbum failed with error: ${err.code}, ${err.message}`);
5671  }
5672}
5673```
5674
5675### placeBefore<sup>11+</sup>
5676
5677placeBefore(album: Album): void;
5678
5679将当前相册排序到目标相册之前。
5680
5681**系统接口**:此接口为系统接口。
5682
5683**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5684
5685**参数:**
5686
5687| 参数名        | 类型      | 必填   | 说明                                 |
5688| ---------- | ------- | ---- | ---------------------------------- |
5689| album | [Album](#album) | 是   |  目标相册。如果要将当前相册排序到末位,则目标相册传入null。 |
5690
5691**错误码:**
5692
5693接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
5694
5695| 错误码ID | 错误信息 |
5696| -------- | ---------------------------------------- |
5697| 202      |  Called by non-system application.         |
5698| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
5699| 14000011       | System inner fail.         |
5700
5701**示例:**
5702
5703```ts
5704async function example() {
5705  console.info('placeBeforeDemo');
5706  try {
5707    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC);
5708    let firstAlbum: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
5709    if (albumFetchResult.isAfterLast()) {
5710      console.error('lack of album to place before');
5711      return;
5712    }
5713    let secondAlbum: photoAccessHelper.Album = await albumFetchResult.getNextObject();
5714    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(secondAlbum);
5715    albumChangeRequest.placeBefore(firstAlbum);
5716    await phAccessHelper.applyChanges(albumChangeRequest);
5717    console.info('placeBefore successfully');
5718  } catch (err) {
5719    console.error(`placeBeforeDemo failed with error: ${err.code}, ${err.message}`);
5720  }
5721}
5722```
5723
5724### dismiss<sup>13+</sup>
5725
5726dismiss(): void
5727
5728删除合影相册。
5729
5730**系统接口**:此接口为系统接口。
5731
5732**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5733
5734**错误码:**
5735
5736接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
5737
5738| 错误码ID    | 错误信息                              |
5739| :------- | :-------------------------------- |
5740| 202      | Called by non-system application. |
5741| 401 | Parameter error. Possible causes: Incorrect parameter types. |
5742| 14000011 | System inner fail.            |
5743
5744**示例:**
5745
5746```ts
5747import { dataSharePredicates } from '@kit.ArkData';
5748
5749async function example() {
5750  console.info('dismissDemo');
5751  try {
5752    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.GROUP_PHOTO);
5753    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
5754
5755    let albumChangeRequest: photoAccessHelper.MediaAlbumChangeRequest = new photoAccessHelper.MediaAlbumChangeRequest(album);
5756    albumChangeRequest.dismiss();
5757    await phAccessHelper.applyChanges(albumChangeRequest);
5758    console.info('dismiss successfully');
5759  } catch (err) {
5760    console.error(`dismissDemo failed with error: ${err.code}, ${err.message}`);
5761  }
5762}
5763```
5764
5765## HighlightAlbum<sup>12+</sup>
5766
5767时刻相册。
5768
5769**系统接口**:此接口为系统接口。
5770
5771**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5772
5773### constructor<sup>12+</sup>
5774
5775constructor(album: Album)
5776
5777构造函数。
5778
5779**系统接口**:此接口为系统接口。
5780
5781**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5782
5783**参数:**
5784
5785| 参数名   | 类型                      | 必填 | 说明       |
5786| -------- | ------------------------- | ---- | ---------- |
5787| album | [Album](#album) | 是   | 智慧相册。 |
5788
5789**错误码:**
5790
5791接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
5792
5793| 错误码ID | 错误信息 |
5794| -------- | ---------------------------------------- |
5795| 202      |  Called by non-system application.   |
5796| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
5797| 14000011 | Internal system error.            |
5798
5799**示例:**
5800
5801```ts
5802import { dataSharePredicates } from '@kit.ArkData';
5803
5804async function example() {
5805  console.info('HighlightAlbum constructorDemo');
5806  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
5807  let fetchOption: photoAccessHelper.FetchOptions = {
5808    fetchColumns: [],
5809    predicates: predicates
5810  };
5811  let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await photoAccessHelper.getAlbums(
5812    photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.HIGHLIGHT, fetchOption);
5813  let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
5814  let highlightAlbum: photoAccessHelper.HighlightAlbum = new photoAccessHelper.HighlightAlbum(album);
5815  albumFetchResult.close();
5816}
5817```
5818
5819### getHighlightAlbumInfo<sup>12+</sup>
5820
5821getHighlightAlbumInfo(type: HighlightAlbumInfoType): Promise&lt;string&gt;
5822
5823获取指定时刻相册的特定信息。
5824
5825**系统接口**:此接口为系统接口。
5826
5827**需要权限**:ohos.permission.READ\_IMAGEVIDEO
5828
5829**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5830
5831**参数:**
5832
5833| 参数名        | 类型      | 必填   | 说明                                 |
5834| ---------- | ------- | ---- | ---------------------------------- |
5835| type       | [HighlightAlbumInfoType](#highlightalbuminfotype12) | 是    | 需要获取的时刻相册信息类型。 |
5836
5837**错误码:**
5838
5839接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
5840
5841| 错误码ID    | 错误信息                              |
5842| :------- | :-------------------------------- |
5843| 201      | Permission denied.                |
5844| 202      | Called by non-system application. |
5845| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
5846| 14000011 | Internal system error.            |
5847
5848**示例:**
5849
5850```ts
5851import { dataSharePredicates } from '@kit.ArkData';
5852
5853async function example() {
5854  try {
5855    console.info('getHighlightAlbumInfoDemo')
5856    let fetchOptions: photoAccessHelper.FetchOptions = {
5857      fetchColumns: [],
5858      predicates: new dataSharePredicates.DataSharePredicates()
5859    }
5860    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await photoAccessHelper.getAlbums(
5861    photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.HIGHLIGHT, fetchOption);
5862    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();、
5863    if (album != undefined) {
5864      let highlightAlbum: photoAccessHelper.HighlightAlbum = new photoAccessHelper.HighlightAlbum(album);
5865      let coverInfo: string = await highlightAlbum.getHighlightAlbumInfo(
5866        photoAccessHelper.HighlightAlbumInfoType.COVER_INFO);
5867      console.info('get cover info result: ' + JSON.stringify(coverInfo));
5868    }
5869
5870    albumFetchResult.close();
5871  } catch (err) {
5872    console.error(`getHighlightAlbumInfoDemofailed with error: ${err.code}, ${err.message}`);
5873  }
5874}
5875```
5876
5877### getHighlightResource<sup>12+</sup>
5878
5879getHighlightResource(resourceUri: string): Promise&lt;ArrayBuffer&gt;
5880
5881获取指定时刻缓存资源的ArrayBuffer。
5882
5883**系统接口**:此接口为系统接口。
5884
5885**需要权限**:ohos.permission.READ\_IMAGEVIDEO
5886
5887**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5888
5889**参数:**
5890
5891| 参数名        | 类型      | 必填   | 说明                                 |
5892| ---------- | ------- | ---- | ---------------------------------- |
5893| resourceUri       | string | 是    | 指定时刻缓存资源uri。 |
5894
5895**错误码:**
5896
5897接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
5898
5899| 错误码ID    | 错误信息                              |
5900| :------- | :-------------------------------- |
5901| 201      | Permission denied.                |
5902| 202      | Called by non-system application. |
5903| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
5904| 14000011 | Internal system error.            |
5905
5906**示例:**
5907
5908```ts
5909import { dataSharePredicates } from '@kit.ArkData';
5910
5911async function example() {
5912  try {
5913    console.info('getHighlightResourceDemo')
5914    let fetchOptions: photoAccessHelper.FetchOptions = {
5915      fetchColumns: [],
5916      predicates: new dataSharePredicates.DataSharePredicates()
5917    }
5918    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await photoAccessHelper.getAlbums(
5919    photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.HIGHLIGHT, fetchOption);
5920    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();、
5921    if (album != undefined) {
5922      let highlightAlbum: photoAccessHelper.HighlightAlbum = new photoAccessHelper.HighlightAlbum(album);
5923      let uri: string = 'file://media/highlight/cover/10/1_1/background.png?oper=highlight'
5924      let arrayBuffer: ArrayBuffer = await highlightAlbum.getHighlightResource(uri);
5925    }
5926    albumFetchResult.close();
5927  } catch (err) {
5928    console.error(`getHighlightResourceDemofailed with error: ${err.code}, ${err.message}`);
5929  }
5930}
5931```
5932
5933### setHighlightUserActionData<sup>12+</sup>
5934
5935setHighlightUserActionData(type: HighlightUserActionType, actionData: number): Promise&lt;void&gt;
5936
5937设置指定时刻用户行为数据。
5938
5939**系统接口**:此接口为系统接口。
5940
5941**需要权限**:ohos.permission.WRITE\_IMAGEVIDEO
5942
5943**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
5944
5945**参数:**
5946
5947| 参数名        | 类型      | 必填   | 说明                                 |
5948| ---------- | ------- | ---- | ---------------------------------- |
5949| type       | [HighlightUserActionType](#highlightuseractiontype12) | 是    | 需要设置的用户行为数据类型。 |
5950| actionData | number | 是    | 行为数据。 |
5951
5952**错误码:**
5953
5954接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
5955
5956| 错误码ID    | 错误信息                              |
5957| :------- | :-------------------------------- |
5958| 201      | Permission denied.                |
5959| 202      | Called by non-system application. |
5960| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
5961| 14000011 | Internal system error.            |
5962
5963**示例:**
5964
5965```ts
5966import { dataSharePredicates } from '@kit.ArkData';
5967
5968async function example() {
5969  try {
5970    console.info('setHighlightUserActionDataDemo')
5971    let fetchOptions: photoAccessHelper.FetchOptions = {
5972      fetchColumns: [],
5973      predicates: new dataSharePredicates.DataSharePredicates()
5974    }
5975    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = await photoAccessHelper.getAlbums(
5976    photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.HIGHLIGHT, fetchOption);
5977    let album: photoAccessHelper.Album = await albumFetchResult.getFirstObject();、
5978    if (album != undefined) {
5979      let highlightAlbum: photoAccessHelper.HighlightAlbum = new photoAccessHelper.HighlightAlbum(album);
5980      highlightAlbum.setHighlightUserActionData(photoAccessHelper.HighlightUserActionType.INSERTED_PIC_COUNT, 1);
5981    }
5982    albumFetchResult.close();
5983  } catch (err) {
5984    console.error(`setHighlightUserActionDataDemofailed with error: ${err.code}, ${err.message}`);
5985  }
5986}
5987```
5988
5989### setSubTitle<sup>18+</sup>
5990
5991setSubTitle(title: string): void
5992
5993设置时刻副标题内容。
5994
5995副标题参数规格为:
5996
5997- 副标题字符串长度为0~255。
5998- 不允许出现的非法英文字符,包括:<br> . \ / : * ? " ' ` < > | { } [ ]
5999- 英文字符大小写不敏感。
6000
6001**系统接口**:此接口为系统接口。
6002
6003**需要权限**:ohos.permission.WRITE\_IMAGEVIDEO
6004
6005**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6006
6007**参数:**
6008
6009| 参数名        | 类型      | 必填   | 说明                                 |
6010| ---------- | ------- | ---- | ---------------------------------- |
6011| title       | string | 是    | 需要设置的时刻副标题内容。 |
6012
6013**错误码:**
6014
6015以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
6016
6017| 错误码ID    | 错误信息                              |
6018| :------- | :-------------------------------- |
6019| 201      | Permission denied.                |
6020| 202      | Called by non-system application. |
6021| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
6022| 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.            |
6023
6024**示例:**
6025
6026```ts
6027import { dataSharePredicates } from '@kit.ArkData';
6028import { common } from '@kit.AbilityKit';
6029
6030// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
6031let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
6032
6033async function example() {
6034  try {
6035    console.info('setSubTitle');
6036    let helper: photoAccessHelper.PhotoAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
6037    let albumFetchOption: photoAccessHelper.FetchOptions = {
6038      fetchColumns: [],
6039      predicates: new dataSharePredicates.DataSharePredicates()
6040    };
6041    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> =
6042      await helper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.HIGHLIGHT, albumFetchOption);
6043    if (albumFetchResult.getCount() === 0) {
6044      console.error('No album');
6045      return;
6046    }
6047    let highlightAlbum: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
6048    albumFetchResult.close();
6049    let changeHighlightAlbumRequest: photoAccessHelper.HighlightAlbum = new photoAccessHelper.HighlightAlbum(highlightAlbum);
6050    changeHighlightAlbumRequest.setSubTitle("testName");
6051    console.info('setSubTitle success');
6052  } catch (err) {
6053    console.error(`setSubTitle with error: ${err}`);
6054  }
6055}
6056```
6057
6058### deleteHighlightAlbums<sup>18+</sup>
6059
6060static deleteHighlightAlbums(context: Context, albums: Array&lt;Album&gt;): Promise&lt;number&gt;
6061
6062删除指定时刻相册。
6063
6064**系统接口**:此接口为系统接口。
6065
6066**需要权限**:ohos.permission.WRITE\_IMAGEVIDEO
6067
6068**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6069
6070**参数:**
6071
6072| 参数名        | 类型      | 必填   | 说明                                 |
6073| ---------- | ------- | ---- | ---------------------------------- |
6074| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | 是   | 传入Ability实例的Context。 |
6075| albums       | Array&lt;[Album](#album)&gt;   | 是    | 需要删除的时刻相册。 |
6076
6077**返回值:**
6078
6079| 类型                | 说明                                |
6080| :------------------ | :---------------------------------- |
6081| Promise&lt;number&gt; | 是否成功删除相册。成功返回0,失败返回1。 |
6082
6083**错误码:**
6084
6085以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
6086
6087| 错误码ID    | 错误信息                              |
6088| :------- | :-------------------------------- |
6089| 201      | Permission denied.                |
6090| 202      | Called by non-system application. |
6091| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
6092| 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.            |
6093
6094**示例:**
6095
6096```ts
6097import { dataSharePredicates } from '@kit.ArkData';
6098import photoAccessHelper from '@ohos.file.photoAccessHelper';
6099import { common } from '@kit.AbilityKit';
6100
6101// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
6102let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
6103
6104async function example() {
6105  try {
6106    console.info('deleteHighlightAlbums');
6107    let helper: photoAccessHelper.PhotoAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
6108    let albumFetchOption: photoAccessHelper.FetchOptions = {
6109      fetchColumns: [],
6110      predicates: new dataSharePredicates.DataSharePredicates()
6111    };
6112    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> =
6113      await helper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.HIGHLIGHT, albumFetchOption);
6114    if (albumFetchResult.getCount() === 0) {
6115      console.error('No album');
6116      return;
6117    }
6118    let highlightAlbum: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
6119    albumFetchResult.close();
6120    let result = await photoAccessHelper.HighlightAlbum.deleteHighlightAlbums(context, [highlightAlbum]);
6121    console.info('deleteHighlightAlbums success');
6122  } catch (err) {
6123    console.error(`deleteHighlightAlbums with error: ${err}`);
6124  }
6125}
6126```
6127
6128## MediaAnalysisAlbumChangeRequest<sup>18+</sup>
6129
6130智慧相册变更请求。
6131
6132**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6133
6134### constructor<sup>18+</sup>
6135
6136constructor(album: Album)
6137
6138构造函数。
6139
6140**系统接口**:此接口为系统接口。
6141
6142**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6143
6144**参数:**
6145
6146| 参数名        | 类型      | 必填   | 说明                                 |
6147| ---------- | ------- | ---- | ---------------------------------- |
6148| album | [Album](#album) | 是   | 智慧相册。 |
6149
6150**错误码:**
6151
6152以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
6153
6154| 错误码ID | 错误信息 |
6155| -------- | ---------------------------------------- |
6156| 202      |  Called by non-system application.   |
6157| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
6158
6159**示例:**
6160
6161```ts
6162import { dataSharePredicates } from '@kit.ArkData';
6163import { common } from '@kit.AbilityKit';s
6164
6165// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
6166let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
6167
6168async function example() {
6169  console.info('MediaAnalysisAlbumChangeRequest constructorDemo');
6170  let helper: photoAccessHelper.PhotoAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
6171  let albumFetchOption: photoAccessHelper.FetchOptions = {
6172    fetchColumns: [],
6173    predicates: new dataSharePredicates.DataSharePredicates()
6174  };
6175  let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> =
6176    await helper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.HIGHLIGHT, albumFetchOption);
6177  if (albumFetchResult.getCount() === 0) {
6178    console.error('No album');
6179    return;
6180  }
6181  let highlightAlbum: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
6182  albumFetchResult.close();
6183  let changeRequest: photoAccessHelper.MediaAnalysisAlbumChangeRequest =
6184    new photoAccessHelper.MediaAnalysisAlbumChangeRequest(highlightAlbum);
6185}
6186```
6187
6188### setOrderPosition<sup>18+</sup>
6189
6190setOrderPosition(assets: Array&lt;PhotoAsset&gt;, position: Array&lt;number&gt;): void
6191
6192设置智慧相册中资产的顺序位置。
6193
6194**系统接口**:此接口为系统接口。
6195
6196**需要权限**:ohos.permission.WRITE\_IMAGEVIDEO
6197
6198**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6199
6200**参数:**
6201
6202| 参数名        | 类型      | 必填   | 说明                                 |
6203| ---------- | ------- | ---- | ---------------------------------- |
6204| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | 是   | 需要设置顺序位置的相册中资产。 |
6205| position       | Array&lt;number&gt;   | 是    | 相册中资产的顺序位置。 |
6206
6207**错误码:**
6208
6209以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
6210
6211| 错误码ID    | 错误信息                              |
6212| :------- | :-------------------------------- |
6213| 201      | Permission denied.                |
6214| 202      | Called by non-system application. |
6215| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
6216| 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.            |
6217
6218**示例:**
6219
6220```ts
6221import { dataSharePredicates } from '@kit.ArkData';
6222import { common } from '@kit.AbilityKit';
6223
6224// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
6225let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
6226
6227async function example() {
6228  try {
6229    console.info('setOrderPosition');
6230    let helper: photoAccessHelper.PhotoAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
6231    let albumFetchOption: photoAccessHelper.FetchOptions = {
6232      fetchColumns: [],
6233      predicates: new dataSharePredicates.DataSharePredicates()
6234    };
6235    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> =
6236      await helper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.HIGHLIGHT, albumFetchOption);
6237    if (albumFetchResult.getCount() === 0) {
6238      console.error('No album');
6239      return;
6240    }
6241    let highlightAlbum: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
6242    albumFetchResult.close();
6243    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6244    const fetchOption: photoAccessHelper.FetchOptions = {
6245      fetchColumns: [],
6246      predicates: predicates
6247    };
6248    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> =
6249      await highlightAlbum.getAssets(fetchOption);
6250    let assets: photoAccessHelper.PhotoAsset[] = await fetchResult.getAllObjects();
6251    let indexes: number[] = [];
6252    for (let i = 0; i < assets.length; i++) {
6253      indexes.push(i);
6254    }
6255    let changeRequest: photoAccessHelper.MediaAnalysisAlbumChangeRequest =
6256      new photoAccessHelper.MediaAnalysisAlbumChangeRequest(highlightAlbum);
6257    changeRequest.setOrderPosition(assets, indexes);
6258    await helper.applyChanges(changeRequest);
6259    console.info(`setOrderPosition ${indexes}`);
6260  } catch (err) {
6261    console.error(`setOrderPosition error: ${err}`);
6262  }
6263}
6264```
6265
6266## AnalysisAlbum<sup>18+</sup>
6267
6268智慧相册。
6269
6270**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6271
6272### constructor<sup>18+</sup>
6273
6274constructor(album: Album)
6275
6276构造函数。
6277
6278**系统接口**:此接口为系统接口。
6279
6280**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6281
6282**参数:**
6283
6284| 参数名        | 类型      | 必填   | 说明                                 |
6285| ---------- | ------- | ---- | ---------------------------------- |
6286| album | [Album](#album) | 是   | 智慧相册。 |
6287
6288**错误码:**
6289
6290以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
6291
6292| 错误码ID | 错误信息 |
6293| -------- | ---------------------------------------- |
6294| 202      |  Called by non-system application.   |
6295| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
6296
6297**示例:**
6298
6299```ts
6300import { dataSharePredicates } from '@kit.ArkData';
6301import { common } from '@kit.AbilityKit';
6302
6303// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
6304let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
6305
6306async function example() {
6307  console.info('AnalysisAlbum constructorDemo');
6308  let helper: photoAccessHelper.PhotoAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
6309  let albumFetchOption: photoAccessHelper.FetchOptions = {
6310    fetchColumns: [],
6311    predicates: new dataSharePredicates.DataSharePredicates()
6312  };
6313  let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> =
6314    await helper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.HIGHLIGHT, albumFetchOption);
6315  if (albumFetchResult.getCount() === 0) {
6316    console.error('No album');
6317    return;
6318  }
6319  let highlightAlbum: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
6320  albumFetchResult.close();
6321  let analysisAlbum: photoAccessHelper.AnalysisAlbum = new photoAccessHelper.AnalysisAlbum(highlightAlbum);
6322}
6323```
6324
6325### getOrderPosition<sup>18+</sup>
6326
6327getOrderPosition(assets: Array&lt;PhotoAsset&gt;): Promise&lt;Array&lt;number&gt;&gt;
6328
6329获取智慧相册中资产的顺序位置。
6330
6331**系统接口**:此接口为系统接口。
6332
6333**需要权限**:ohos.permission.READ\_IMAGEVIDEO
6334
6335**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6336
6337**参数:**
6338
6339| 参数名        | 类型      | 必填   | 说明                                 |
6340| ---------- | ------- | ---- | ---------------------------------- |
6341| assets | Array&lt;[PhotoAsset](#photoasset)&gt; | 是   | 需要获取顺序位置的相册中资产。 |
6342
6343**返回值:**
6344
6345| 类型                | 说明                                |
6346| :------------------ | :---------------------------------- |
6347| Promise&lt;Array&lt;number&gt;&gt; | 相册中资产的顺序位置值。 |
6348
6349**错误码:**
6350
6351以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
6352
6353| 错误码ID    | 错误信息                              |
6354| :------- | :-------------------------------- |
6355| 201      | Permission denied.                |
6356| 202      | Called by non-system application. |
6357| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
6358| 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.            |
6359
6360**示例:**
6361
6362```ts
6363import { dataSharePredicates } from '@kit.ArkData';
6364import { common } from '@kit.AbilityKit';
6365
6366// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
6367let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
6368
6369async function example() {
6370  try {
6371    console.info('getOrderPosition');
6372    let helper: photoAccessHelper.PhotoAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
6373    let albumFetchOption: photoAccessHelper.FetchOptions = {
6374      fetchColumns: [],
6375      predicates: new dataSharePredicates.DataSharePredicates()
6376    };
6377    let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> =
6378      await helper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.HIGHLIGHT, albumFetchOption);
6379    if (albumFetchResult.getCount() === 0) {
6380      console.error('No album');
6381      return;
6382    }
6383    let highlightAlbum: photoAccessHelper.Album = await albumFetchResult.getFirstObject();
6384    albumFetchResult.close();
6385    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6386    let analysisAlbum: photoAccessHelper.AnalysisAlbum = new photoAccessHelper.AnalysisAlbum(highlightAlbum);
6387    const fetchOption: photoAccessHelper.FetchOptions = {
6388      fetchColumns: [],
6389      predicates: predicates
6390    };
6391    let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> =
6392      await highlightAlbum.getAssets(fetchOption);
6393    let assets: photoAccessHelper.PhotoAsset[] = await fetchResult.getAllObjects();
6394    let positions: number[] = await analysisAlbum.getOrderPosition(assets);
6395    console.info(`getOrderPosition ${positions}`);
6396  } catch (err) {
6397    console.error(`getOrderPosition error: ${err}`);
6398  }
6399}
6400```
6401
6402## CloudEnhancement<sup>13+</sup>
6403
6404云增强管理类,该类用于生成AI云增强照片任务的管理、获取原照片与AI云增强照片的关联关系。
6405
6406**系统接口**:此接口为系统接口。
6407
6408**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6409
6410### getCloudEnhancementInstance<sup>13+</sup>
6411
6412static getCloudEnhancementInstance(context: Context): CloudEnhancement
6413
6414获取云增强类实例。
6415
6416**系统接口**:此接口为系统接口。
6417
6418**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6419
6420**参数:**
6421
6422| 参数名   | 类型                      | 必填 | 说明       |
6423| -------- | ------------------------- | ---- | ---------- |
6424| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | 是   | 传入Ability实例的Context。 |
6425
6426**错误码:**
6427
6428接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
6429
6430| 错误码ID | 错误信息 |
6431| -------- | ---------------------------------------- |
6432| 202      |  Called by non-system application.   |
6433| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
6434| 14000011 | Internal system error.            |
6435
6436**示例:**
6437
6438```ts
6439import { dataSharePredicates } from '@kit.ArkData';
6440
6441async function example() {
6442  console.info('getCloudEnhancementInstanceDemo');
6443  let photoPredicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6444  let photoFetchOptions: photoAccessHelper.FetchOptions = {
6445    fetchColumns: [],
6446    predicates: photoPredicates
6447  };
6448  let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
6449  try {
6450    let fetchResult = await phAccessHelper.getAssets(photoFetchOptions);
6451    let asset = await fetchResult.getLastObject();
6452    let cloudEnhancementInstance: photoAccessHelper.CloudEnhancement
6453      = photoAccessHelper.CloudEnhancement.getCloudEnhancementInstance(context);
6454    let hasCloudWatermark = true;
6455    await cloudEnhancementInstance.submitCloudEnhancementTasks([asset], hasCloudWatermark);
6456  } catch (err) {
6457    console.error(`getCloudEnhancementInstanceDemo failed with error: ${err.code}, ${err.message}`);
6458  }
6459}
6460```
6461
6462### submitCloudEnhancementTasks<sup>13+</sup>
6463
6464submitCloudEnhancementTasks(photoAssets: Array&lt;PhotoAsset&gt;, hasCloudWatermark: boolean): Promise&lt;void&gt;
6465
6466提交云增强任务。
6467
6468**系统接口**:此接口为系统接口。
6469
6470**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6471
6472**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
6473
6474**参数:**
6475
6476| 参数名   | 类型                      | 必填 | 说明       |
6477| -------- | ------------------------- | ---- | ---------- |
6478| photoAssets | Array<[PhotoAsset](#photoasset)> | 是   | 需要增强照片的[PhotoAsset](#photoasset)集合。 |
6479| hasCloudWatermark | boolean | 是   | 增强后图片是否添加云增强水印。 |
6480
6481**错误码:**
6482
6483接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
6484
6485| 错误码ID | 错误信息 |
6486| -------- | ---------------------------------------- |
6487| 201      | Permission denied.                |
6488| 202      | Called by non-system application. |
6489| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
6490| 14000011 | Internal system error.            |
6491
6492**示例:**
6493
6494```ts
6495import { dataSharePredicates } from '@kit.ArkData';
6496
6497async function example() {
6498  console.info('submitCloudEnhancementTasksDemo');
6499  let photoPredicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6500  let photoFetchOptions: photoAccessHelper.FetchOptions = {
6501    fetchColumns: [],
6502    predicates: photoPredicates
6503  };
6504  let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
6505  try {
6506    let fetchResult = await phAccessHelper.getAssets(photoFetchOptions);
6507    let asset = await fetchResult.getLastObject();
6508    let cloudEnhancementInstance: photoAccessHelper.CloudEnhancement
6509      = photoAccessHelper.CloudEnhancement.getCloudEnhancementInstance(context);
6510    let hasCloudWatermark = true;
6511    await cloudEnhancementInstance.submitCloudEnhancementTasks([asset], hasCloudWatermark);
6512  } catch (err) {
6513    console.error(`submitCloudEnhancementTasksDemo failed with error: ${err.code}, ${err.message}`);
6514  }
6515}
6516```
6517
6518### submitCloudEnhancementTasks<sup>18+</sup>
6519
6520submitCloudEnhancementTasks(photoAssets: Array&lt;PhotoAsset&gt;, hasCloudWatermark: boolean, triggerMode?: number): Promise&lt;void&gt;
6521
6522提交云增强任务。
6523
6524**系统接口**:此接口为系统接口。
6525
6526**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6527
6528**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
6529
6530**参数:**
6531
6532| 参数名   | 类型                      | 必填 | 说明       |
6533| -------- | ------------------------- | ---- | ---------- |
6534| photoAssets | Array<[PhotoAsset](#photoasset)> | 是   | 需要增强照片的[PhotoAsset](#photoasset)集合。 |
6535| hasCloudWatermark | boolean | 是   | 若为true,增强后图片添加云增强水印;若为false,增强后图片不添加云增强水印。 |
6536| triggerMode | number | 否   | 云增强任务触发类型。<br>- 0:手动触发。<br>- 1:自动触发。<br>- 默认值为0。 |
6537
6538**错误码:**
6539
6540以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
6541
6542| 错误码ID | 错误信息 |
6543| -------- | ---------------------------------------- |
6544| 201      | Permission denied.                |
6545| 202      | Called by non-system application. |
6546| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
6547| 14000011 | Internal system error.            |
6548
6549**示例:**
6550
6551```ts
6552import { dataSharePredicates } from '@kit.ArkData';
6553
6554async function example() {
6555  console.info('submitCloudEnhancementTasksDemo');
6556  let photoPredicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6557  let photoFetchOptions: photoAccessHelper.FetchOptions = {
6558    fetchColumns: [],
6559    predicates: photoPredicates
6560  };
6561  let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
6562  try {
6563    let fetchResult = await phAccessHelper.getAssets(photoFetchOptions);
6564    let asset = await fetchResult.getLastObject();
6565    let cloudEnhancementInstance: photoAccessHelper.CloudEnhancement
6566      = photoAccessHelper.CloudEnhancement.getCloudEnhancementInstance(context);
6567    let hasCloudWatermark = true;
6568    let triggerAuto = 1;
6569    await cloudEnhancementInstance.submitCloudEnhancementTasks([asset], hasCloudWatermark, triggerAuto);
6570  } catch (err) {
6571    console.error(`submitCloudEnhancementTasksDemo failed with error: ${err.code}, ${err.message}`);
6572  }
6573}
6574```
6575
6576### prioritizeCloudEnhancementTask<sup>13+</sup>
6577
6578prioritizeCloudEnhancementTask(photoAsset: PhotoAsset): Promise&lt;void&gt;
6579
6580提升指定云增强任务的优先级。
6581
6582**系统接口**:此接口为系统接口。
6583
6584**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6585
6586**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
6587
6588**参数:**
6589
6590| 参数名   | 类型                      | 必填 | 说明       |
6591| -------- | ------------------------- | ---- | ---------- |
6592| photoAsset | [PhotoAsset](#photoasset) | 是   | 需要修改云增强优先级照片的[PhotoAsset](#photoasset)。 |
6593
6594**错误码:**
6595
6596接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
6597
6598| 错误码ID | 错误信息 |
6599| -------- | ---------------------------------------- |
6600| 201      | Permission denied.                |
6601| 202      | Called by non-system application. |
6602| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
6603| 14000011 | Internal system error.            |
6604
6605**示例:**
6606
6607```ts
6608import { dataSharePredicates } from '@kit.ArkData';
6609
6610async function example() {
6611  console.info('prioritizeCloudEnhancementTaskDemo');
6612  let photoPredicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6613  // 查询进行中的云增强任务。
6614  photoPredicates.equalTo(photoAccessHelper.PhotoKeys.CE_AVAILABLE, 2);
6615  let photoFetchOptions: photoAccessHelper.FetchOptions = {
6616    fetchColumns: [],
6617    predicates: photoPredicates
6618  };
6619  let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
6620  try {
6621    let fetchResult = await phAccessHelper.getAssets(photoFetchOptions);
6622    let asset = await fetchResult.getLastObject();
6623    let cloudEnhancementInstance: photoAccessHelper.CloudEnhancement
6624      = photoAccessHelper.CloudEnhancement.getCloudEnhancementInstance(context);
6625    let hasCloudWatermark = true;
6626    await cloudEnhancementInstance.prioritizeCloudEnhancementTask(asset);
6627  } catch (err) {
6628    console.error(`prioritizeCloudEnhancementTaskDemo failed with error: ${err.code}, ${err.message}`);
6629  }
6630}
6631```
6632
6633### cancelCloudEnhancementTasks<sup>13+</sup>
6634
6635cancelCloudEnhancementTasks(photoAssets: Array&lt;PhotoAsset&gt;): Promise&lt;void&gt;
6636
6637取消指定云增强任务。
6638
6639**系统接口**:此接口为系统接口。
6640
6641**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6642
6643**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
6644
6645**参数:**
6646
6647| 参数名   | 类型                      | 必填 | 说明       |
6648| -------- | ------------------------- | ---- | ---------- |
6649| photoAssets | Array<[PhotoAsset](#photoasset)> | 是   | 需要取消云增强任务的[PhotoAsset](#photoasset)集合。 |
6650
6651**错误码:**
6652
6653接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
6654
6655| 错误码ID | 错误信息 |
6656| -------- | ---------------------------------------- |
6657| 201      | Permission denied.                |
6658| 202      | Called by non-system application. |
6659| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
6660| 14000011 | Internal system error.            |
6661
6662**示例:**
6663
6664```ts
6665import { dataSharePredicates } from '@kit.ArkData';
6666
6667async function example() {
6668  console.info('cancelCloudEnhancementTasksDemo');
6669  let photoPredicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6670  // 查询进行中的云增强任务。
6671  photoPredicates.equalTo(photoAccessHelper.PhotoKeys.CE_AVAILABLE, 2);
6672  let photoFetchOptions: photoAccessHelper.FetchOptions = {
6673    fetchColumns: [],
6674    predicates: photoPredicates
6675  };
6676  let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
6677  try {
6678    let fetchResult = await phAccessHelper.getAssets(photoFetchOptions);
6679    let asset = await fetchResult.getLastObject();
6680    let cloudEnhancementInstance: photoAccessHelper.CloudEnhancement
6681      = photoAccessHelper.CloudEnhancement.getCloudEnhancementInstance(context);
6682    await cloudEnhancementInstance.cancelCloudEnhancementTasks([asset]);
6683  } catch (err) {
6684    console.error(`cancelCloudEnhancementTasksDemo failed with error: ${err.code}, ${err.message}`);
6685  }
6686}
6687```
6688
6689### cancelAllCloudEnhancementTasks<sup>13+</sup>
6690
6691cancelAllCloudEnhancementTasks(): Promise&lt;void&gt;
6692
6693取消全部云增强任务。
6694
6695**系统接口**:此接口为系统接口。
6696
6697**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6698
6699**需要权限**:ohos.permission.WRITE_IMAGEVIDEO
6700
6701**错误码:**
6702
6703接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
6704
6705| 错误码ID | 错误信息 |
6706| -------- | ---------------------------------------- |
6707| 201      | Permission denied.                |
6708| 202      | Called by non-system application. |
6709| 14000011 | Internal system error.            |
6710
6711**示例:**
6712
6713```ts
6714import { dataSharePredicates } from '@kit.ArkData';
6715
6716async function example() {
6717  console.info('cancelAllCloudEnhancementTasksDemo');
6718  try {
6719    let cloudEnhancementInstance: photoAccessHelper.CloudEnhancement
6720      = photoAccessHelper.CloudEnhancement.getCloudEnhancementInstance(context);
6721    await cloudEnhancementInstance.cancelCloudEnhancementTasks();
6722  } catch (err) {
6723    console.error(`cancelAllCloudEnhancementTasksDemo failed with error: ${err.code}, ${err.message}`);
6724  }
6725}
6726```
6727
6728### queryCloudEnhancementTaskState<sup>13+</sup>
6729
6730queryCloudEnhancementTaskState(photoAsset: PhotoAsset): Promise&lt;CloudEnhancementTaskState&gt;
6731
6732查询云增强任务信息。
6733
6734**系统接口**:此接口为系统接口。
6735
6736**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6737
6738**需要权限**:ohos.permission.READ_IMAGEVIDEO
6739
6740**参数:**
6741
6742| 参数名   | 类型                      | 必填 | 说明       |
6743| -------- | ------------------------- | ---- | ---------- |
6744| photoAsset | [PhotoAsset](#photoasset) | 是   | 需要查询云增强任务信息的[PhotoAsset](#photoasset)。 |
6745
6746**错误码:**
6747
6748接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
6749
6750| 错误码ID | 错误信息 |
6751| -------- | ---------------------------------------- |
6752| 201      | Permission denied.                |
6753| 202      | Called by non-system application. |
6754| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
6755| 14000011 | Internal system error.            |
6756
6757**示例:**
6758
6759```ts
6760import { dataSharePredicates } from '@kit.ArkData';
6761
6762async function example() {
6763  console.info('queryCloudEnhancementTaskStateDemo');
6764  let photoPredicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6765  // 查询进行中的云增强任务。
6766  photoPredicates.equalTo(photoAccessHelper.PhotoKeys.CE_AVAILABLE, 2);
6767  let photoFetchOptions: photoAccessHelper.FetchOptions = {
6768    fetchColumns: [],
6769    predicates: photoPredicates
6770  };
6771  let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
6772  try {
6773    let fetchResult = await phAccessHelper.getAssets(photoFetchOptions);
6774    let asset = await fetchResult.getLastObject();
6775    let cloudEnhancementInstance: photoAccessHelper.CloudEnhancement
6776      = photoAccessHelper.CloudEnhancement.getCloudEnhancementInstance(context);
6777    const cloudEnhancementTaskState: photoAccessHelper.CloudEnhancementTaskState
6778      = await cloudEnhancementInstance.queryCloudEnhancementTaskState(asset);
6779    let taskStage = cloudEnhancementTaskState.taskStage;
6780    if (taskStage == photoAccessHelper.CloudEnhancementTaskStage.TASK_STAGE_EXCEPTION) {
6781      console.log("task has exception");
6782    } else if (taskStage == photoAccessHelper.CloudEnhancementTaskStage.TASK_STAGE_PREPARING) {
6783      console.log("task is preparing");
6784    } else if (taskStage == photoAccessHelper.CloudEnhancementTaskStage.TASK_STAGE_UPLOADING) {
6785      let transferredFileSize = cloudEnhancementTaskState.transferredFileSize;
6786      let totalFileSize = cloudEnhancementTaskState.totalFileSize;
6787      let message = `task is uploading, transferredFileSize: ${transferredFileSize}, totalFileSize: ${totalFileSize}`;
6788      console.log(message);
6789    } else if (taskStage == photoAccessHelper.CloudEnhancementTaskStage.TASK_STAGE_EXECUTING) {
6790      let expectedDuration = cloudEnhancementTaskState.expectedDuration;
6791      let message = `task is executing, expectedDuration: ${expectedDuration}`;
6792      console.log(message);
6793    } else if (taskStage == photoAccessHelper.CloudEnhancementTaskStage.TASK_STAGE_DOWNLOADING) {
6794      let transferredFileSize = cloudEnhancementTaskState.transferredFileSize;
6795      let totalFileSize = cloudEnhancementTaskState.totalFileSize;
6796      let message = `task is downloading, transferredFileSize: ${transferredFileSize}, totalFileSize: ${totalFileSize}`;
6797      console.log(message);
6798    } else if (taskStage == photoAccessHelper.CloudEnhancementTaskStage.TASK_STAGE_FAILED) {
6799      let errCode = cloudEnhancementTaskState.statusCode;
6800      let message = `task is failed, errCode: ${errCode}`;
6801      console.log(message);
6802    } else if (taskStage == photoAccessHelper.CloudEnhancementTaskStage.TASK_STAGE_COMPLETED) {
6803      console.log("task is completed");
6804    }
6805  } catch (err) {
6806    console.error(`queryCloudEnhancementTaskStateDemo failed with error: ${err.code}, ${err.message}`);
6807  }
6808}
6809```
6810
6811### syncCloudEnhancementTaskStatus<sup>13+</sup>
6812
6813syncCloudEnhancementTaskStatus(): Promise&lt;void&gt;
6814
6815同步云增强任务状态。
6816
6817**系统接口**:此接口为系统接口。
6818
6819**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6820
6821**需要权限**:ohos.permission.READ_IMAGEVIDEO
6822
6823**错误码:**
6824
6825接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
6826
6827| 错误码ID | 错误信息 |
6828| -------- | ---------------------------------------- |
6829| 201      | Permission denied.                |
6830| 202      | Called by non-system application. |
6831| 14000011 | Internal system error.            |
6832
6833**示例:**
6834
6835```ts
6836import { dataSharePredicates } from '@kit.ArkData';
6837
6838async function example() {
6839  console.info('syncCloudEnhancementTaskStatusDemo');
6840  try {
6841    let cloudEnhancementInstance: photoAccessHelper.CloudEnhancement
6842      = photoAccessHelper.CloudEnhancement.getCloudEnhancementInstance(context);
6843    await cloudEnhancementInstance.syncCloudEnhancementTaskStatus();
6844  } catch (err) {
6845    console.error(`syncCloudEnhancementTaskStatusDemo failed with error: ${err.code}, ${err.message}`);
6846  }
6847}
6848```
6849
6850### getCloudEnhancementPair<sup>13+</sup>
6851
6852getCloudEnhancementPair(asset: PhotoAsset): Promise&lt;PhotoAsset&gt;
6853
6854查询云增强配对照片。
6855
6856**系统接口**:此接口为系统接口。
6857
6858**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6859
6860**需要权限**:ohos.permission.READ_IMAGEVIDEO
6861
6862**参数:**
6863
6864| 参数名   | 类型                      | 必填 | 说明       |
6865| -------- | ------------------------- | ---- | ---------- |
6866| photoAsset | [PhotoAsset](#photoasset) | 是   | 需要查询云增强配对照片的[PhotoAsset](#photoasset)。 |
6867
6868**错误码:**
6869
6870接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
6871
6872| 错误码ID | 错误信息 |
6873| -------- | ---------------------------------------- |
6874| 201      | Permission denied.                |
6875| 202      | Called by non-system application. |
6876| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
6877| 14000011 | Internal system error.            |
6878
6879**示例:**
6880
6881```ts
6882import { dataSharePredicates } from '@kit.ArkData';
6883
6884async function example() {
6885  console.info('getCloudEnhancementPairDemo');
6886  let photoPredicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6887  // 查询已完成的云增强任务。
6888  photoPredicates.equalTo(photoAccessHelper.PhotoKeys.CE_AVAILABLE, 5);
6889  let photoFetchOptions: photoAccessHelper.FetchOptions = {
6890    fetchColumns: [],
6891    predicates: photoPredicates
6892  };
6893  let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
6894  try {
6895    let fetchResult = await phAccessHelper.getAssets(photoFetchOptions);
6896    let asset = await fetchResult.getLastObject();
6897    let cloudEnhancementInstance: photoAccessHelper.CloudEnhancement
6898      = photoAccessHelper.CloudEnhancement.getCloudEnhancementInstance(context);
6899    let photoAsset: photoAccessHelper.PhotoAsset
6900      = await cloudEnhancementInstance.getCloudEnhancementPair(asset);
6901  } catch (err) {
6902    console.error(`getCloudEnhancementPairDemo failed with error: ${err.code}, ${err.message}`);
6903  }
6904}
6905```
6906
6907### setVideoEnhancementAttr<sup>13+</sup>
6908
6909setVideoEnhancementAttr(videoEnhancementType: VideoEnhancementType, photoId: string): Promise&lt;void&gt;
6910
6911设置视频的二阶段增强处理类型。
6912
6913**系统接口**:此接口为系统接口。
6914
6915**需要权限**:ohos.permission.WRITE\_IMAGEVIDEO
6916
6917**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6918
6919**参数:**
6920
6921| 参数名        | 类型      | 必填   | 说明                                 |
6922| ---------- | ------- | ---- | ---------------------------------- |
6923| videoEnhancementType       | [VideoEnhancementType](#videoenhancementtype13) | 是    | 需要进行分段式视频的处理类型。 |
6924| photoId | string | 是    | 图片的photoId。 |
6925
6926**错误码:**
6927
6928接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
6929
6930| 错误码ID    | 错误信息                              |
6931| :------- | :-------------------------------- |
6932| 202      | Called by non-system application. |
6933| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
6934| 14000011 | Internal system error.            |
6935| 14000016 | Operation Not Support.            |
6936
6937**示例:**
6938
6939```ts
6940async function example(asset: photoAccessHelper.PhotoAsset) {
6941  try {
6942    let assetChangeRequest: photoAccessHelper.MediaAssetChangeRequest = new photoAccessHelper.MediaAssetChangeRequest(asset);
6943    let photoId = "202410011800";
6944    assetChangeRequest.setVideoEnhancementAttr(photoAccessHelper.VideoEnhancementType.QUALITY_ENHANCEMENT_LOCAL, photoId);
6945    await phAccessHelper.applyChanges(assetChangeRequest);
6946  } catch (err) {
6947    console.error(`setVideoEnhancementAttr fail with error: ${err.code}, ${err.message}`);
6948  }
6949}
6950```
6951
6952### getFaceId<sup>13+</sup>
6953
6954getFaceId(): Promise\<string>
6955
6956获取人像相册或合影相册的封面人脸标识。
6957
6958**系统接口**:此接口为系统接口。
6959
6960**需要权限**:ohos.permission.READ\_IMAGEVIDEO
6961
6962**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
6963
6964**返回值:**
6965
6966| 类型                | 说明                                |
6967| :------------------ | :---------------------------------- |
6968| Promise&lt;string&gt; | Promise对象,人像相册返回tag_id,合影相册返回group_tag,未找到返回空字符串。 |
6969
6970**错误码:**
6971
6972接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
6973
6974| 错误码ID | 错误信息                                                     |
6975| :------- | :----------------------------------------------------------- |
6976| 201      | Permission denied.                                           |
6977| 202      | Called by non-system application.                            |
6978| 14000011 | Internal system error                                        |
6979
6980**示例:**
6981
6982```ts
6983import { dataSharePredicates } from '@kit.ArkData';
6984
6985async function example() {
6986  try {
6987    console.info('getFaceIdDemo');
6988    let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
6989    predicates.equalTo("user_display_level", 1);
6990    let fetchOptions: photoAccessHelper.FetchOptions = {
6991      fetchColumns: [],
6992      predicates: predicates
6993    };
6994    let fetchResult =
6995      await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.SMART, photoAccessHelper.AlbumSubtype.PORTRAIT,
6996        fetchOptions);
6997    let album = await fetchResult?.getFirstObject();
6998    let faceId = await album?.getFaceId();
6999    console.info(`getFaceId successfully, faceId: ${faceId}`);
7000    fetchResult.close();
7001  } catch (err) {
7002    console.error(`getFaceId failed with err: ${err.code}, ${err.message}`);
7003  }
7004}
7005```
7006
7007## CloudMediaAssetManager<sup>14+</sup>
7008
7009云端媒体资产管理类,该类用于管理云端资产的下载任务,以及删除云端资产在本地的数据和文件。
7010
7011**系统接口**:此接口为系统接口。
7012
7013**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7014
7015### getCloudMediaAssetManagerInstance<sup>14+</sup>
7016
7017static getCloudMediaAssetManagerInstance(context: Context): CloudMediaAssetManager
7018
7019获取云端媒体资产管理类实例。
7020
7021**系统接口**:此接口为系统接口。
7022
7023**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7024
7025**参数:**
7026
7027| 参数名   | 类型                      | 必填 | 说明       |
7028| -------- | ------------------------- | ---- | ---------- |
7029| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md) | 是   | 传入Ability实例的Context。 |
7030
7031**返回值:**
7032
7033| 类型                                    | 说明              |
7034| --------------------------------------- | ----------------- |
7035| [CloudMediaAssetManager](#cloudmediaassetmanager14) | 返回云端媒体资产管理类实例。 |
7036
7037**错误码:**
7038
7039接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
7040
7041| 错误码ID | 错误信息 |
7042| -------- | ---------------------------------------- |
7043| 202      |  Called by non-system application.   |
7044| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
7045| 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.          |
7046
7047**示例:**
7048
7049```ts
7050import { photoAccessHelper } from '@kit.MediaLibraryKit';
7051import { common } from '@kit.AbilityKit';
7052
7053// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
7054let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
7055
7056async function example() {
7057  console.info('getCloudMediaAssetManagerInstanceDemo');
7058  try {
7059    let cloudMediaAssetManagerInstance: photoAccessHelper.CloudMediaAssetManager
7060      = photoAccessHelper.CloudMediaAssetManager.getCloudMediaAssetManagerInstance(context);
7061    await cloudMediaAssetManagerInstance.pauseDownloadCloudMedia();
7062  } catch (err) {
7063    console.error(`getCloudMediaAssetManagerInstanceDemo failed with error: ${err.code}, ${err.message}`);
7064  }
7065}
7066```
7067
7068### startDownloadCloudMedia<sup>14+</sup>
7069
7070startDownloadCloudMedia(downloadType: CloudMediaDownloadType): Promise&lt;void&gt;
7071
7072开始或恢复云端媒体资产下载任务。
7073
7074**系统接口**:此接口为系统接口。
7075
7076**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7077
7078**参数:**
7079
7080| 参数名   | 类型                      | 必填 | 说明       |
7081| -------- | ------------------------- | ---- | ---------- |
7082| downloadType | [CloudMediaDownloadType](#cloudmediadownloadtype14) | 是   | 云端媒体资产的下载方式。 |
7083
7084**返回值:**
7085
7086| 类型                                    | 说明              |
7087| --------------------------------------- | ----------------- |
7088| Promise&lt;void&gt;| Promise对象,返回void。 |
7089
7090**错误码:**
7091
7092接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
7093
7094| 错误码ID | 错误信息 |
7095| -------- | ---------------------------------------- |
7096| 201      | Permission denied.                |
7097| 202      | Called by non-system application. |
7098| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
7099| 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.           |
7100
7101**示例:**
7102
7103```ts
7104import { photoAccessHelper } from '@kit.MediaLibraryKit';
7105import { common } from '@kit.AbilityKit';
7106
7107// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
7108let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
7109
7110async function example() {
7111  console.info('startDownloadCloudMediaDemo');
7112  try {
7113    let cloudMediaAssetManagerInstance: photoAccessHelper.CloudMediaAssetManager
7114      = photoAccessHelper.CloudMediaAssetManager.getCloudMediaAssetManagerInstance(context);
7115    await cloudMediaAssetManagerInstance.startDownloadCloudMedia(photoAccessHelper.CloudMediaDownloadType.DOWNLOAD_FORCE);
7116  } catch (err) {
7117    console.error(`startDownloadCloudMediaDemo failed with error: ${err.code}, ${err.message}`);
7118  }
7119}
7120```
7121
7122### pauseDownloadCloudMedia<sup>14+</sup>
7123
7124pauseDownloadCloudMedia(): Promise&lt;void&gt;
7125
7126暂停云端媒体资产下载任务。
7127
7128**系统接口**:此接口为系统接口。
7129
7130**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7131
7132**返回值:**
7133
7134| 类型                                    | 说明              |
7135| --------------------------------------- | ----------------- |
7136| Promise&lt;void&gt;| Promise对象,返回void。 |
7137
7138**错误码:**
7139
7140接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
7141
7142| 错误码ID | 错误信息 |
7143| -------- | ---------------------------------------- |
7144| 201      | Permission denied.                |
7145| 202      | Called by non-system application. |
7146| 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.            |
7147
7148**示例:**
7149
7150```ts
7151import { photoAccessHelper } from '@kit.MediaLibraryKit';
7152import { common } from '@kit.AbilityKit';
7153
7154// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
7155let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
7156
7157async function example() {
7158  console.info('pauseDownloadCloudMediaDemo');
7159  try {
7160    let cloudMediaAssetManagerInstance: photoAccessHelper.CloudMediaAssetManager
7161      = photoAccessHelper.CloudMediaAssetManager.getCloudMediaAssetManagerInstance(context);
7162    await cloudMediaAssetManagerInstance.pauseDownloadCloudMedia();
7163  } catch (err) {
7164    console.error(`pauseDownloadCloudMediaDemo failed with error: ${err.code}, ${err.message}`);
7165  }
7166}
7167```
7168
7169### cancelDownloadCloudMedia<sup>14+</sup>
7170
7171cancelDownloadCloudMedia(): Promise&lt;void&gt;
7172
7173取消云端媒体资产下载任务。
7174
7175**系统接口**:此接口为系统接口。
7176
7177**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7178
7179**返回值:**
7180
7181| 类型                                    | 说明              |
7182| --------------------------------------- | ----------------- |
7183| Promise&lt;void&gt;| Promise对象,返回void。 |
7184
7185**错误码:**
7186
7187接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
7188
7189| 错误码ID | 错误信息 |
7190| -------- | ---------------------------------------- |
7191| 201      | Permission denied.                |
7192| 202      | Called by non-system application. |
7193| 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.            |
7194
7195**示例:**
7196
7197```ts
7198import { photoAccessHelper } from '@kit.MediaLibraryKit';
7199import { common } from '@kit.AbilityKit';
7200
7201// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
7202let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
7203
7204async function example() {
7205  console.info('cancelDownloadCloudMediaDemo');
7206  try {
7207    let cloudMediaAssetManagerInstance: photoAccessHelper.CloudMediaAssetManager
7208      = photoAccessHelper.CloudMediaAssetManager.getCloudMediaAssetManagerInstance(context);
7209    await cloudMediaAssetManagerInstance.cancelDownloadCloudMedia();
7210  } catch (err) {
7211    console.error(`cancelDownloadCloudMediaDemo failed with error: ${err.code}, ${err.message}`);
7212  }
7213}
7214```
7215
7216### retainCloudMediaAsset<sup>14+</sup>
7217
7218retainCloudMediaAsset(retainType: CloudMediaRetainType): Promise&lt;void&gt;
7219
7220删除云端媒体资产在本地的元数据和文件。
7221
7222**系统接口**:此接口为系统接口。
7223
7224**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7225
7226**参数:**
7227
7228| 参数名   | 类型                      | 必填 | 说明       |
7229| -------- | ------------------------- | ---- | ---------- |
7230| retainType | [CloudMediaRetainType](#cloudmediaretaintype14) | 是   | 云端媒体资产的删除方式。 |
7231
7232**返回值:**
7233
7234| 类型                                    | 说明              |
7235| --------------------------------------- | ----------------- |
7236| Promise&lt;void&gt;| Promise对象,返回void。 |
7237
7238**错误码:**
7239
7240接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
7241
7242| 错误码ID | 错误信息 |
7243| -------- | ---------------------------------------- |
7244| 201      | Permission denied.                |
7245| 202      | Called by non-system application. |
7246| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
7247| 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.            |
7248
7249**示例:**
7250
7251```ts
7252import { photoAccessHelper } from '@kit.MediaLibraryKit';
7253import { common } from '@kit.AbilityKit';
7254
7255// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
7256let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
7257
7258async function example() {
7259  console.info('retainCloudMediaAssetDemo');
7260  try {
7261    let cloudMediaAssetManagerInstance: photoAccessHelper.CloudMediaAssetManager
7262      = photoAccessHelper.CloudMediaAssetManager.getCloudMediaAssetManagerInstance(context);
7263    await cloudMediaAssetManagerInstance.retainCloudMediaAsset(photoAccessHelper.CloudMediaRetainType.RETAIN_FORCE);
7264  } catch (err) {
7265    console.error(`retainCloudMediaAssetDemo failed with error: ${err.code}, ${err.message}`);
7266  }
7267}
7268```
7269
7270### getCloudMediaAssetStatus<sup>14+</sup>
7271
7272getCloudMediaAssetStatus(): Promise&lt;CloudMediaAssetStatus&gt;
7273
7274查询云端媒体资产下载任务状态。
7275
7276**系统接口**:此接口为系统接口。
7277
7278**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7279
7280**返回值:**
7281
7282| 类型                                    | 说明              |
7283| --------------------------------------- | ----------------- |
7284|Promise&lt;[CloudMediaAssetStatus](#cloudmediaassetstatus14)&gt; | Promise对象,返回云端媒体资产下载任务状态。 |
7285
7286**错误码:**
7287
7288接口抛出错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[文件管理错误码](../apis-core-file-kit/errorcode-filemanagement.md)。
7289
7290| 错误码ID | 错误信息 |
7291| -------- | ---------------------------------------- |
7292| 201      | Permission denied.                |
7293| 202      | Called by non-system application. |
7294| 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.            |
7295
7296**示例:**
7297
7298```ts
7299import { photoAccessHelper } from '@kit.MediaLibraryKit';
7300import { common } from '@kit.AbilityKit';
7301
7302// 请在组件内获取context,确保this.getUiContext().getHostContext()返回结果为UIAbilityContext
7303let context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext;
7304
7305async function example() {
7306  console.info('getCloudMediaAssetStatusDemo');
7307  try {
7308    let cloudMediaAssetManagerInstance: photoAccessHelper.CloudMediaAssetManager
7309      = photoAccessHelper.CloudMediaAssetManager.getCloudMediaAssetManagerInstance(context);
7310    const cloudMediaAssetStatus: photoAccessHelper.CloudMediaAssetStatus = await cloudMediaAssetManagerInstance.getCloudMediaAssetStatus();
7311    let taskStatus = cloudMediaAssetStatus.taskStatus;
7312    let taskInfo = cloudMediaAssetStatus.taskInfo;
7313    let errorCode = cloudMediaAssetStatus.errorCode;
7314    let message = `taskStatus: ${taskStatus}, taskInfo: ${taskInfo}, errorCode: ${errorCode}`;
7315    console.log(message);
7316  } catch (err) {
7317    console.error(`getCloudMediaAssetStatusDemo failed with error: ${err.code}, ${err.message}`);
7318  }
7319}
7320```
7321
7322## PhotoSelectOptions
7323
7324图库选择选项子类,继承于BaseSelectOptions。用于拉起对应userId空间的picker。
7325
7326**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7327
7328| 参数名 | 类型 | 必填 | 说明 |
7329| -------- | -------- | -------- | -------- |
7330| userId<sup>18+</sup> | number  | 否   | 指定访问空间的Id。默认值为-1。<br>当需要作为[PhotoViewPicker.select](js-apis-photoAccessHelper.md#select)的选择参数时,请申请ohos.permission.INTERACTA_CROSS_LOCAL_ACCOUNTS。<br>**系统接口**:此接口为系统接口。 |
7331
7332**示例:**
7333
7334```ts
7335  private photoPicker() {
7336    let picker = new photoAccessHelper.PhotoViewPicker();
7337    let option = new photoAccessHelper.PhotoSelectOptions();
7338    option.userId = 101;
7339    picker.select(option);
7340  }
7341```
7342
7343## PhotoSubtype
7344
7345枚举,不同[PhotoAsset](#photoasset)的类型。
7346
7347**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7348
7349| 名称  |  值 |  说明 |
7350| ----- |  ---- |  ---- |
7351| SCREENSHOT |  1 |  截屏录屏文件类型。<br>**系统接口**:此接口为系统接口。 |
7352
7353## AlbumType
7354
7355枚举,相册类型,表示是用户相册还是系统预置相册。
7356
7357**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7358
7359| 名称                  | 值    | 说明                        |
7360| ------------------- | ---- | ------------------------- |
7361| SOURCE<sup>18+</sup> | 2048 | 来源相册。<br>**系统接口**:此接口为系统接口。 |
7362| SMART<sup>11+</sup> | 4096 | 智慧分析相册。<br>**系统接口**:此接口为系统接口。 |
7363
7364## AlbumSubtype
7365
7366枚举,相册子类型,表示具体的相册类型。
7367
7368**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7369
7370| 名称                                | 值          | 说明                              |
7371| --------------------------------- | ---------- | ------------------------------- |
7372| HIDDEN                            | 1027       | 隐藏相册。**系统接口**:此接口为系统接口。         |
7373| TRASH                             | 1028       | 回收站。**系统接口**:此接口为系统接口。          |
7374| SCREENSHOT                        | 1029       | 截屏和录屏相册。**系统接口**:此接口为系统接口。      |
7375| CAMERA                            | 1030       | 相机拍摄的照片和视频相册。**系统接口**:此接口为系统接口。 |
7376| SOURCE\_GENERIC<sup>11+</sup>     | 2049       | 来源相册。**系统接口**:此接口为系统接口。         |
7377| CLASSIFY<sup>11+</sup>            | 4097       | 分类相册。**系统接口**:此接口为系统接口。         |
7378| GEOGRAPHY\_LOCATION<sup>11+</sup> | 4099       | 地图相册。**系统接口**:此接口为系统接口。         |
7379| GEOGRAPHY\_CITY<sup>11+</sup>     | 4100       | 城市相册。**系统接口**:此接口为系统接口。         |
7380| SHOOTING\_MODE<sup>11+</sup>      | 4101       | 拍摄模式相册。**系统接口**:此接口为系统接口。       |
7381| PORTRAIT<sup>11+</sup>            | 4102       | 人像相册。**系统接口**:此接口为系统接口。         |
7382| GROUP_PHOTO<sup>13+</sup>         | 4103       | 合影相册。**系统接口**:此接口为系统接口。         |
7383| HIGHLIGHT<sup>12+</sup>           | 4104       | 时刻相册。**系统接口**:此接口为系统接口。         |
7384| HIGHLIGHT_SUGGESTIONS<sup>12+</sup> | 4105     | 时刻建议相册。**系统接口**:此接口为系统接口。         |
7385| CLOUD_ENHANCEMENT<sup>13+</sup> | 1032     | AI云增强相册。**系统接口**:此接口为系统接口。         |
7386
7387## RequestPhotoType<sup>11+</sup>
7388
7389枚举,获取图片或视频缩略图的操作类型。
7390
7391**系统接口**:此接口为系统接口。
7392
7393**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7394
7395| 名称  |  值 |  说明 |
7396| ----- |  ---- |  ---- |
7397| REQUEST_ALL_THUMBNAILS  |  0 |  即获取快速缩略图,又获取质量缩略图。 |
7398| REQUEST_FAST_THUMBNAIL |  1 |  只获取快速缩略图。 |
7399| REQUEST_QUALITY_THUMBNAIL |  2 |  只获取质量缩略图。 |
7400
7401## PhotoKeys
7402
7403枚举,图片和视频文件关键信息。
7404
7405**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7406
7407| 名称          | 值              | 说明                                                       |
7408| ------------- | ------------------- | ---------------------------------------------------------- |
7409| DATE_TRASHED  | 'date_trashed'  | 删除日期(删除文件时间距1970年1月1日的秒数值)。**系统接口**:此接口为系统接口。                 |
7410| HIDDEN  | 'hidden'            | 文件的隐藏状态。**系统接口**:此接口为系统接口。                               |
7411| CAMERA_SHOT_KEY  | 'camera_shot_key'  | 锁屏相机拍照或录像的标记字段(仅开放给系统相机,其key值由系统相机定义)。**系统接口**:此接口为系统接口。            |
7412| USER_COMMENT<sup>10+</sup>  | 'user_comment'            | 用户注释信息。**系统接口**:此接口为系统接口。           |
7413| DATE_YEAR<sup>11+</sup>  | 'date_year'            | 创建文件的年份。**系统接口**:此接口为系统接口。           |
7414| DATE_MONTH<sup>11+</sup>  | 'date_month'            | 创建文件的月份。**系统接口**:此接口为系统接口。           |
7415| DATE_DAY<sup>11+</sup>  | 'date_day'            | 创建文件的日期。**系统接口**:此接口为系统接口。           |
7416| PENDING<sup>11+</sup>  | 'pending'            | pending状态。**系统接口**:此接口为系统接口。           |
7417| DATE_TRASHED_MS<sup>12+</sup>  | 'date_trashed_ms'  | 删除日期(删除文件时间距1970年1月1日的毫秒数值)。**系统接口**:此接口为系统接口。<br>注意:查询照片时,不支持基于该字段排序。 |
7418| MOVING_PHOTO_EFFECT_MODE<sup>12+</sup>  | 'moving_photo_effect_mode' | 动态照片效果模式。**系统接口**:此接口为系统接口。 |
7419| CE_AVAILABLE<sup>13+</sup>  | 'ce_available' | 云增强任务标识。**系统接口**:此接口为系统接口。 |
7420| SUPPORTED_WATERMARK_TYPE<sup>14+</sup>  | 'supported_watermark_type' | 水印可编辑标识。**系统接口**:此接口为系统接口。 |
7421| IS_CE_AUTO<sup>18+</sup>  | 'is_auto' | 是否支持自动云增强。**系统接口**:此接口为系统接口。 |
7422| OWNER_ALBUM_ID<sup>18+</sup>  | 'owner_album_id' | 照片所属的相册id。**系统接口**:此接口为系统接口。 |
7423| IS_RECENT_SHOW<sup>18+</sup>  | 'is_recent_show' | 是否设置为最近显示。**系统接口**:此接口为系统接口。 |
7424
7425## AlbumKeys
7426
7427枚举,相册关键信息。
7428
7429**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7430
7431| 名称                              | 值                    | 说明                                                       |
7432| --------------------------------- | -------------------- | ----------------------------------------------------- |
7433| ALBUM_LPATH<sup>18+</sup>          | 'lpath'                 | 相册的虚拟路径。<br>**系统接口**:此接口为系统接口。            |
7434| BUNDLE_NAME<sup>18+</sup>          | 'bundle_name'                 | 相册的包名。<br>**系统接口**:此接口为系统接口。            |
7435| DATE_MODIFIED<sup>18+</sup>        | 'date_modified'         | 相册修改的时间戳(单位:毫秒)。<br>**系统接口**:此接口为系统接口。            |
7436
7437## HiddenPhotosDisplayMode<sup>11+</sup>
7438
7439枚举,系统中隐藏文件显示模式。
7440
7441**系统接口**:此接口为系统接口。
7442
7443**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7444
7445| 名称          | 值              | 说明                                                       |
7446| ------------- | ------------------- | ---------------------------------------------------------- |
7447| ASSETS_MODE   | 0       | 按系统预置的隐藏相册显示隐藏文件,即显示系统中所有的隐藏文件。    |
7448| ALBUMS_MODE    | 1    | 按相册显示隐藏文件(即显示系统中所有包含隐藏文件的相册,除系统预置的隐藏相册本身和回收站相册以外)。  |
7449
7450## PhotoCreateOptions
7451
7452图片或视频的创建选项。
7453
7454**系统接口**:此接口为系统接口。
7455
7456**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7457
7458| 名称                   | 类型                | 必填 | 说明                                              |
7459| ---------------------- | ------------------- | ---- | ------------------------------------------------ |
7460| subtype           | [PhotoSubtype](#photosubtype) | 否  | 图片或者视频的子类型。  |
7461| cameraShotKey           | string | 否  | 锁屏相机拍照或录像的标记字段(仅开放给系统相机,其key值由系统相机定义)。   |
7462
7463## RequestPhotoOptions<sup>11+</sup>
7464
7465获取图片或视频缩略图的选项。
7466
7467**系统接口**:此接口为系统接口。
7468
7469**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7470
7471| 名称                   | 类型                | 必填 | 说明                                              |
7472| ---------------------- | ------------------- | ---- | ------------------------------------------------ |
7473| size           | [image.Size](../apis-image-kit/js-apis-image.md#size) | 否  | 获取缩略图的尺寸。  |
7474| requestPhotoType    | [RequestPhotoType](#requestphototype11) | 否  | 获取的操作类型。  |
7475
7476## PhotoCreationSource<sup>18+</sup>
7477
7478代替应用创建资产传入的应用信息。
7479
7480**系统接口**:此接口为系统接口。
7481
7482**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7483
7484| 名称                   | 类型                | 只读 | 可选 | 说明                                              |
7485| ---------------------- | ------------------- | ---- | ---- | ------------------------------------------------ |
7486| bundleName           | string | 是  | 是  |需保存图片/视频文件的应用bundle name。  |
7487| appName    | string | 是  | 是  |需保存图片/视频文件的app name。  |
7488| appId    | string | 是  | 是  |需保存图片/视频文件的app id。  |
7489| tokenId    | number | 是  | 是  |应用标识,将访问权限授予tokenId标识的应用。  |
7490
7491## RequestOptions<sup>11+</sup>
7492
7493请求策略。
7494
7495**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7496
7497| 名称                   | 类型                              | 可读 | 可写 | 说明                                              |
7498| ---------------------- |---------------------------------| ---- |---- | ------------------------------------------------ |
7499| sourceMode           | [SourceMode](#sourcemode11)     | 是   | 是   | 资源文件的读取类型,可以指定当前请求获取的是源文件,或是编辑后的文件。**系统接口**:此接口为系统接口。 |
7500
7501## PhotoProxy<sup>11+</sup>
7502
7503照片代理,相机应用通过该对象写入图片数据。
7504
7505**系统接口**:此接口为系统接口。
7506
7507**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7508
7509## MediaChangeRequest<sup>11+</sup>
7510
7511媒体变更请求,资产变更请求和相册变更请求的父类型。
7512
7513**注意**:媒体变更请求需要在调用[applyChanges](js-apis-photoAccessHelper.md#applychanges11)后才会提交生效。
7514
7515**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7516
7517## FormInfo<sup>11+</sup>
7518
7519图库卡片相关信息。
7520
7521**系统接口**:此接口为系统接口。
7522
7523**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7524
7525| 名称                   | 类型                | 必填 | 说明                                              |
7526| ---------------------- | ------------------- | ---- | ------------------------------------------------ |
7527|formId       |string  |是 | 卡片的ID,由图库创建卡片时提供。 |
7528|uri          |string  |是 | 卡片绑定的图片的uri。创建卡片时uri可为空或图片的uri,移除卡片时uri不做校验,传空即可。  |
7529
7530## GalleryFormInfo<sup>18+</sup>
7531
7532图库卡片相关信息。
7533
7534**系统接口**:此接口为系统接口。
7535
7536**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7537
7538| 名称                   | 类型                | 必填 | 说明                                              |
7539| ---------------------- | ------------------- | ---- | ------------------------------------------------ |
7540|formId             |string               |是 | 卡片的ID,由图库创建卡片时提供。 |
7541|assetUris          |Array&lt;string&gt;  |是 | 卡片绑定的图片或相册的uri集合。创建和更新卡片时assetUris不可为空,移除卡片时assetUris可以不传。  |
7542
7543## ResourceType<sup>11+</sup>
7544
7545枚举,写入资源的类型。
7546
7547**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7548
7549| 名称  |  值 |  说明 |
7550| ----- |  ---- |  ---- |
7551| PHOTO_PROXY |  3 |  表示照片代理资源。**系统接口**:此接口为系统接口。 |
7552| PRIVATE_MOVING_PHOTO_RESOURCE<sup>13+</sup> |  4 |  表示私有动态照片资源。**系统接口**:此接口为系统接口。 |
7553| PRIVATE_MOVING_PHOTO_METADATA<sup>18+</sup> |  5 |  表示私有动态照片元数据资源。**系统接口**:此接口为系统接口。 |
7554
7555## DefaultChangeUri
7556
7557枚举,DefaultChangeUri子类型。
7558
7559**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7560
7561| 名称              | 值                      | 说明                                                         |
7562| ----------------- | ----------------------- | ------------------------------------------------------------ |
7563| DEFAULT_HIDDEN_ALBUM_URI<sup>11+</sup>  | 'file://media/HiddenAlbum' | 隐藏相册-相册视图中相册的Uri,即系统中包含隐藏文件的相册(不包含系统预置隐藏相册和回收站相册)的Uri,仅用于隐藏相册-相册视图场景的通知。**系统接口**:此接口为系统接口。 |
7564
7565## SourceMode<sup>11+</sup>
7566
7567枚举,资源文件的读取类型。
7568
7569**系统接口**:此接口为系统接口。
7570
7571**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7572
7573| 名称  |  值 |  说明 |
7574| ----- |  ---- |  ---- |
7575| ORIGINAL_MODE |  0 |  读取源文件。 |
7576| EDITED_MODE |  1 |  读取编辑后的文件。|
7577## AuthorizationMode<sup>12+</sup>
7578
7579枚举,授权模式。
7580
7581**系统接口**:此接口为系统接口。
7582
7583**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7584
7585| 名称  |  值 |  说明 |
7586| ----- |  ---- |  ---- |
7587| SHORT_TIME_AUTHORIZATION|  0 |  短时授权。 |
7588
7589## AnalysisType<sup>11+</sup>
7590
7591枚举,智慧分析类型。
7592
7593**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7594
7595| 名称                            | 值  | 说明       |
7596| :---------------------------- | :- | :------- |
7597| ANALYSIS\_AESTHETICS\_SCORE   | 0  | 美学评分分析类别。**系统接口**:此接口为系统接口。    |
7598| ANALYSIS\_LABEL               | 1  | 分类标签分析类别。**系统接口**:此接口为系统接口。    |
7599| ANALYSIS\_OCR                 | 2  | 文字识别分析类别。**系统接口**:此接口为系统接口。    |
7600| ANALYSIS\_FACE                | 3  | 人脸检测分析类别。**系统接口**:此接口为系统接口。    |
7601| ANALYSIS\_OBJECT              | 4  | 目标检测分析类别。**系统接口**:此接口为系统接口。    |
7602| ANALYSIS\_RECOMMENDATION      | 5  | 推荐构图分析类别。**系统接口**:此接口为系统接口。    |
7603| ANALYSIS\_SEGMENTATION        | 6  | 抠图分析类别。**系统接口**:此接口为系统接口。    |
7604| ANALYSIS\_COMPOSITION         | 7  | 美学构图分析类别。**系统接口**:此接口为系统接口。   |
7605| ANALYSIS\_SALIENCY            | 8  | 最佳呈现主体中心分析类别。**系统接口**:此接口为系统接口。   |
7606| ANALYSIS\_DETAIL\_ADDRESS     | 9  | 详细地址分析类别。**系统接口**:此接口为系统接口。    |
7607| ANALYSIS\_HUMAN\_FACE\_TAG<sup>12+</sup>    | 10 | 人像聚类信息分析类别。**系统接口**:此接口为系统接口。    |
7608| ANALYSIS\_HEAD\_POSITION<sup>12+</sup>      | 11 | 人头、宠物头位置分析类别。**系统接口**:此接口为系统接口。    |
7609| ANALYSIS\_BONE\_POSE<sup>12+</sup>        | 12 | 人体骨骼点信息分析类别。**系统接口**:此接口为系统接口。    |
7610| ANALYSIS\_VIDEO\_LABEL<sup>12+</sup>        | 13 | 视频标签。**系统接口**:此接口为系统接口。    |
7611
7612## HighlightAlbumInfoType<sup>12+</sup>
7613
7614枚举,时刻相册信息类型。
7615
7616**系统接口**:此接口为系统接口。
7617
7618**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7619
7620| 名称            | 值  | 说明       |
7621| :------------ | :- | :------- |
7622| COVER\_INFO   | 0  | 封面信息类别。    |
7623| PLAY\_INFO    | 1  | 音乐信息类别。    |
7624
7625## HighlightUserActionType<sup>12+</sup>
7626
7627枚举,时刻用户行为类型。
7628
7629**系统接口**:此接口为系统接口。
7630
7631**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7632
7633| 名称                           | 值  | 说明       |
7634| :---------------------------- | :- | :------- |
7635| INSERTED\_PIC\_COUNT          | 0  | 新增图片数量类别。    |
7636| REMOVED\_PIC\_COUNT           | 1  | 移除图片数量类别。    |
7637| SHARED\_SCREENSHOT\_COUNT     | 2  | 分享二级界面长图次数类别。    |
7638| SHARED\_COVER\_COUNT          | 3  | 分享时刻封面次数类别。    |
7639| RENAMED\_COUNT                | 4  | 重命名次数类别。    |
7640| CHANGED\_COVER\_COUNT         | 5  | 修改封面次数类别。    |
7641| RENDER\_VIEWED\_TIMES         | 100  | 轮播观看次数类别。    |
7642| RENDER\_VIEWED\_DURATION      | 101  | 轮播观看总时长类别。   |
7643| ART\_LAYOUT\_VIEWED\_TIMES    | 102  | 二级界面观看次数类别。   |
7644| ART\_LAYOUT\_VIEWED\_DURATION | 103  | 二级界面观看总时长类别。    |
7645
7646## MovingPhotoEffectMode<sup>12+</sup>
7647
7648枚举,动态照片效果模式。
7649
7650**系统接口**:此接口为系统接口。
7651
7652**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7653
7654| 名称                           | 值  | 说明       |
7655| :---------------------------- | :- | :------- |
7656| DEFAULT          | 0  | 默认模式。|
7657| BOUNCE\_PLAY     | 1  | 来回播放。|
7658| LOOP\_PLAY       | 2  | 循环播放。|
7659| LONG\_EXPOSURE   | 3  | 长曝光。  |
7660| MULTI\_EXPOSURE  | 4  | 多曝光。  |
7661| CINEMA\_GRAPH<sup>13+</sup>  | 5  | 微动瞬间。  |
7662| IMAGE\_ONLY<sup>13+</sup>  | 10  | 关闭模式。  |
7663
7664## PhotoPermissionType<sup>12+</sup>
7665
7666枚举,应用对媒体资源不同访问权限的类型。
7667
7668包括临时读权限和永久读权限,临时读权限会随着应用的死亡而删除,永久读权限不会。
7669
7670同一个应用对同一个媒体资源的权限覆盖规则:永久读会覆盖临时读,而临时读不会覆盖永久读。
7671
7672**系统接口**:此接口为系统接口。
7673
7674**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7675
7676| 名称  |  值 |  说明 |
7677| ----- |  ---- |  ---- |
7678| TEMPORARY_READ_IMAGEVIDEO |  0 |  临时读权限类型。 |
7679| PERSISTENT_READ_IMAGEVIDEO |  1 |  永久读权限类型。 |
7680
7681## HideSensitiveType<sup>12+</sup>
7682
7683枚举,应用访问媒体资源时,对媒体资源进行信息脱敏的类型。
7684
7685**系统接口**:此接口为系统接口。
7686
7687**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7688
7689| 名称  |  值 |  说明 |
7690| ----- |  ---- |  ---- |
7691| HIDE_LOCATION_AND_SHOOTING_PARAM |  0 |  脱敏地理位置和拍摄参数。 |
7692| HIDE_LOCATION_ONLY |  1 |  脱敏地理位置信息。 |
7693| HIDE_SHOOTING_PARAM_ONLY |  2 |  脱敏拍摄参数。 |
7694| NO_HIDE_SENSITIVE_TYPE |  3 |  不脱敏。 |
7695
7696## CloudEnhancementTaskStage<sup>13+</sup>
7697
7698枚举,应用查询云增强任务状态时,在[CloudEnhancementTaskState](#cloudenhancement13)接口中返回,表示云增强任务状态。
7699
7700**系统接口**:此接口为系统接口。
7701
7702**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7703
7704| 名称  |  值 |  说明 |
7705| ----- |  ---- |  ---- |
7706| TASK_STAGE_EXCEPTION |  -1 |  云增强任务异常。 |
7707| TASK_STAGE_PREPARING |  0 |  云增强任务准备中。 |
7708| TASK_STAGE_UPLOADING |  1 |  云增强任务上传中。 |
7709| TASK_STAGE_EXECUTING |  2 |  云增强任务执行中。 |
7710| TASK_STAGE_DOWNLOADING |  3 |  云增强任务下载中。 |
7711| TASK_STAGE_FAILED |  4 |  云增强任务失败。 |
7712| TASK_STAGE_COMPLETED |  5 |  云增强任务已完成。 |
7713
7714## CloudEnhancementState<sup>13+</sup>
7715
7716枚举,表示云增强状态。
7717
7718**系统接口**:此接口为系统接口。
7719
7720**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7721
7722| 名称  |  值 |  说明 |
7723| ----- |  ---- |  ---- |
7724| UNAVAILABLE |  0 |  云增强不可用。 |
7725| AVAILABLE |  1 |  云增强可用。 |
7726| EXECUTING |  2 |  云增强执行中。 |
7727| COMPLETED |  3 |  云增强已完成。 |
7728
7729## CloudEnhancementTaskState<sup>13+</sup>
7730
7731云增强任务状态,应用调用调用云增强任务查询接口的返回类型,包含云增强任务状态及部分状态下的额外信息。
7732
7733**系统接口**:此接口为系统接口。
7734
7735**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7736
7737| 名称                   | 类型                | 必定提供 | 说明                                              |
7738| ---------------------- | ------------------- | ---- | ------------------------------------------------ |
7739|taskStage       |[CloudEnhancementTaskStage](#cloudenhancementtaskstage13)  |是 | 云增强任务状态。 |
7740|transferredFileSize          |number  |否 | 已传输的文件大小。当taskStage为CloudEnhancementTaskStage.TASK_STAGE_UPLOADING或者CloudEnhancementTaskStage.TASK_STAGE_DOWNLOADING时提供。  |
7741|totalFileSize          |number  |否 | 总文件大小。当taskStage为CloudEnhancementTaskStage.TASK_STAGE_UPLOADING或者CloudEnhancementTaskStage.TASK_STAGE_DOWNLOADING时提供。  |
7742|expectedDuration          |number  |否 | 排队时间。当taskStage为CloudEnhancementTaskStage.TASK_STAGE_EXECUTING时提供。  |
7743|statusCode          |number  |否 | 状态码。当taskStage为CloudEnhancementTaskStage.TASK_STAGE_FAILED时提供。  |
7744
7745## VideoEnhancementType<sup>13+</sup>
7746
7747枚举,分段式视频的二段式触发类型。
7748
7749**系统接口**:此接口为系统接口。
7750
7751**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7752
7753| 名称  |  值 |  说明 |
7754| ----- |  ---- |  ---- |
7755| QUALITY_ENHANCEMENT_LOCAL |  0 |  在端侧增强处理。 |
7756| QUALITY_ENHANCEMENT_CLOUD |  1 |  在云侧增强处理。 |
7757| QUALITY_ENHANCEMENT_LOCAL_AND_CLOUD |  2 |  在端侧和云侧同时增强处理。 |
7758
7759## ThumbnailType<sup>13+</sup>
7760
7761枚举,缩略图类型。
7762
7763**系统接口**:此接口为系统接口。
7764
7765**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7766
7767| 名称                           | 值  | 说明       |
7768| :---------------------------- | :- | :------- |
7769| LCD         | 1  | 获取LCD缩略图    |
7770| THM          | 2 | 获取THM缩略图    |
7771
7772## WatermarkType<sup>14+</sup>
7773
7774枚举,水印可编辑标识。
7775
7776**系统接口**:此接口为系统接口。
7777
7778**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7779
7780| 名称  |  值 |  说明 |
7781| ----- |  ---- |  ---- |
7782| DEFAULT |  0 |  不支持水印可编辑。 |
7783| BRAND_COMMON |  1 |  支持品牌和通用水印可编辑。 |
7784| COMMON |  2 |  支持通用水印可编辑。 |
7785| BRAND |  3 |  支持品牌水印可编辑。 |
7786
7787## CloudMediaDownloadType<sup>14+</sup>
7788
7789枚举,表示云端媒体资产的下载方式。
7790
7791**系统接口**:此接口为系统接口。
7792
7793**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7794
7795| 名称  |  值 |  说明 |
7796| ----- |  ---- |  ---- |
7797| DOWNLOAD_FORCE |  0 |  高优先级下载,无需进入息屏充电模式。 |
7798| DOWNLOAD_GENTLE |  1 |  低优先级下载,需要进入息屏充电模式。 |
7799
7800## CloudMediaRetainType<sup>14+</sup>
7801
7802枚举,表示云端媒体资产的删除方式。
7803
7804**系统接口**:此接口为系统接口。
7805
7806**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7807
7808| 名称  |  值 |  说明 |
7809| ----- |  ---- |  ---- |
7810| RETAIN_FORCE |  0 |  删除原文件在云端的本地元数据和缩略图。 |
7811
7812## CloudMediaAssetTaskStatus<sup>14+</sup>
7813
7814枚举,表示云端媒体资产的下载任务状态。
7815
7816**系统接口**:此接口为系统接口。
7817
7818**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7819
7820| 名称  |  值 |  说明 |
7821| ----- |  ---- |  ---- |
7822| DOWNLOADING |  0 |  当前任务下载中。 |
7823| PAUSED |  1 |  当前任务已暂停。 |
7824| IDLE |  2 |  当前无下载任务。 |
7825
7826## CloudMediaTaskPauseCause<sup>14+</sup>
7827
7828枚举,表示云端媒体资产下载任务暂停的类型。
7829
7830**系统接口**:此接口为系统接口。
7831
7832**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7833
7834| 名称  |  值 |  说明 |
7835| ----- |  ---- |  ---- |
7836| NO_PAUSE  |  0 |  正常下载,无暂停。 |
7837| TEMPERATURE_LIMIT |  1 |  温度过高。 |
7838| ROM_LIMIT |  2 |  本地磁盘空间不足。 |
7839| NETWORK_FLOW_LIMIT |  3 |  流量使用有限制,且没有Wi-Fi。 |
7840| WIFI_UNAVAILABLE |  4 |  网络异常。 |
7841| POWER_LIMIT |  5 |  功耗限制。 |
7842| BACKGROUND_TASK_UNAVAILABLE |  6 |  充电息屏未启动。 |
7843| FREQUENT_USER_REQUESTS |  7 |  用户请求频繁。 |
7844| CLOUD_ERROR |  8 |  端云错误。 |
7845| USER_PAUSED |  9 |  用户暂停。 |
7846
7847## CloudMediaAssetStatus<sup>14+</sup>
7848
7849云端媒体资产下载任务的详细信息,应用调用云端资产下载任务查询接口的返回类型。
7850
7851**系统接口**:此接口为系统接口。
7852
7853**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core
7854
7855| 名称                   | 类型                | 必定提供 | 说明                                              |
7856| ---------------------- | ------------------- | ---- | ------------------------------------------------ |
7857|taskStatus       |[CloudMediaAssetTaskStatus](#cloudmediaassettaskstatus14)  |是 | 云端媒体资产下载任务状态。 |
7858|taskInfo          |string  |是 | 下载资产的的总个数和总大小(byte),以及未下载的总个数和总大小(byte)。  |
7859|errorCode       |[CloudMediaTaskPauseCause](#cloudmediataskpausecause14)  |是 | 云端媒体资产下载任务暂停类型。 |