• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Class (MediaAssetManager)
2<!--Kit: Media Library Kit-->
3<!--Subsystem: Multimedia-->
4<!--Owner: @yixiaoff-->
5<!--SE: @liweilu1-->
6<!--TSE: @xchaosioda-->
7
8> **NOTE**
9>
10> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
11> - The initial APIs of this class are supported since API version 11.
12
13The MediaAssetManager class is used for manipulating the read and write operations of media assets.
14
15**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
16
17## Modules to Import
18
19```ts
20import { photoAccessHelper } from '@kit.MediaLibraryKit';
21```
22
23## requestImage<sup>11+</sup>
24
25static requestImage(context: Context, asset: PhotoAsset, requestOptions: RequestOptions, dataHandler: MediaAssetDataHandler&lt;image.ImageSource&gt;): Promise&lt;string&gt;
26
27Requests an image.
28
29**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
30
31**Required permissions**: ohos.permission.READ_IMAGEVIDEO
32
33- When you call this API in Picker mode, you do not need to request the ohos.permission.READ_IMAGEVIDEO permission. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
34- For the media assets saved to the media library by this application, the application can access them without the ohos.permission.READ_IMAGEVIDEO permission.
35
36**Parameters**
37
38| Name           | Type                                                                                                       | Mandatory| Description                     |
39|----------------|-----------------------------------------------------------------------------------------------------------| ---- | ------------------------- |
40| context        | [Context](../apis-ability-kit/js-apis-inner-application-context.md)                                                           | Yes  | Context of the ability instance.|
41| asset         | [PhotoAsset](arkts-apis-photoAccessHelper-PhotoAsset.md)                                                                                | Yes  | Image to request.|
42| requestOptions | [RequestOptions](arkts-apis-photoAccessHelper-i.md#requestoptions11)                                                                        | Yes  | Options for requesting the image.|
43| dataHandler    | [MediaAssetDataHandler](arkts-apis-photoAccessHelper-MediaAssetDataHandler.md)&lt;[image.ImageSource](../apis-image-kit/arkts-apis-image-ImageSource.md)&gt; | Yes  | Media asset handler, which invokes a callback to return the image when the requested image is ready.|
44
45**Return value**
46
47| Type                                   | Description             |
48| --------------------------------------- | ----------------- |
49| Promise\<string> | Promise used to return the request ID, which can be used in [cancelRequest](#cancelrequest12) to cancel a request.|
50
51**Error codes**
52
53For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
54
55| ID| Error Message|
56| -------- | ---------------------------------------- |
57| 201      |  Permission denied         |
58| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
59| 14000011       | System inner fail.        |
60
61**Example**
62
63For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
64
65```ts
66import { dataSharePredicates } from '@kit.ArkData';
67import { image } from '@kit.ImageKit';
68
69class MediaHandler implements photoAccessHelper.MediaAssetDataHandler<image.ImageSource> {
70  onDataPrepared(data: image.ImageSource) {
71    if (data === undefined) {
72      console.error('Error occurred when preparing data');
73      return;
74    }
75    console.info('on image data prepared');
76  }
77}
78
79async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper, context: Context) {
80  console.info('requestImage');
81  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
82  let fetchOptions: photoAccessHelper.FetchOptions = {
83    fetchColumns: [],
84    predicates: predicates
85  };
86  let requestOptions: photoAccessHelper.RequestOptions = {
87    deliveryMode: photoAccessHelper.DeliveryMode.HIGH_QUALITY_MODE,
88  }
89  const handler = new MediaHandler();
90
91  phAccessHelper.getAssets(fetchOptions, async (err, fetchResult) => {
92      console.info('fetchResult success');
93      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
94      await photoAccessHelper.MediaAssetManager.requestImage(context, photoAsset, requestOptions, handler);
95      console.info('requestImage successfully');
96  });
97}
98```
99
100## requestImageData<sup>11+</sup>
101
102static requestImageData(context: Context, asset: PhotoAsset, requestOptions: RequestOptions, dataHandler: MediaAssetDataHandler&lt;ArrayBuffer&gt;): Promise&lt;string&gt;
103
104Requests image data.
105
106**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
107
108**Required permissions**: ohos.permission.READ_IMAGEVIDEO
109
110- When you call this API in Picker mode, you do not need to request the ohos.permission.READ_IMAGEVIDEO permission. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
111- For the media assets saved to the media library by this application, the application can access them without the ohos.permission.READ_IMAGEVIDEO permission.
112
113**Parameters**
114
115| Name  | Type                                                                  | Mandatory| Description                     |
116| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
117| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md)                      | Yes  | Context of the ability instance.|
118| asset | [PhotoAsset](arkts-apis-photoAccessHelper-PhotoAsset.md)                                            | Yes  | Image to request.|
119| requestOptions  | [RequestOptions](arkts-apis-photoAccessHelper-i.md#requestoptions11)                                  | Yes  | Options for requesting the image.|
120| dataHandler  | [MediaAssetDataHandler](arkts-apis-photoAccessHelper-MediaAssetDataHandler.md)&lt;ArrayBuffer&gt; | Yes  | Media asset handler, which invokes a callback to return the image when the requested image is ready.|
121
122**Return value**
123
124| Type                                   | Description             |
125| --------------------------------------- | ----------------- |
126| Promise\<string> | Promise used to return the request ID, which can be used in [cancelRequest](#cancelrequest12) to cancel a request.|
127
128**Error codes**
129
130For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
131
132| ID| Error Message|
133| -------- | ---------------------------------------- |
134| 201      |  Permission denied         |
135| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
136| 14000011       | System inner fail.        |
137
138**Example**
139
140For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
141
142```ts
143import { dataSharePredicates } from '@kit.ArkData';
144
145class MediaDataHandler implements photoAccessHelper.MediaAssetDataHandler<ArrayBuffer> {
146  onDataPrepared(data: ArrayBuffer) {
147    if (data === undefined) {
148      console.error('Error occurred when preparing data');
149      return;
150    }
151    console.info('on image data prepared');
152  }
153}
154
155async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper, context: Context) {
156  console.info('requestImageData');
157  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
158  let fetchOptions: photoAccessHelper.FetchOptions = {
159    fetchColumns: [],
160    predicates: predicates
161  };
162  let requestOptions: photoAccessHelper.RequestOptions = {
163    deliveryMode: photoAccessHelper.DeliveryMode.HIGH_QUALITY_MODE,
164  }
165  const handler = new MediaDataHandler();
166
167  phAccessHelper.getAssets(fetchOptions, async (err, fetchResult) => {
168      console.info('fetchResult success');
169      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
170      await photoAccessHelper.MediaAssetManager.requestImageData(context, photoAsset, requestOptions, handler);
171      console.info('requestImageData successfully');
172  });
173}
174```
175
176## requestMovingPhoto<sup>12+</sup>
177
178static requestMovingPhoto(context: Context, asset: PhotoAsset, requestOptions: RequestOptions, dataHandler: MediaAssetDataHandler&lt;MovingPhoto&gt;): Promise&lt;string&gt;
179
180Requests a moving photo object, which can be used to request the asset data of the moving photo.
181
182**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
183
184**Required permissions**: ohos.permission.READ_IMAGEVIDEO
185
186- When you call this API in Picker mode, you do not need to request the ohos.permission.READ_IMAGEVIDEO permission. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
187- For the moving photos saved to the media library by this application, the application can access them without the ohos.permission.READ_IMAGEVIDEO permission.
188
189**Parameters**
190
191| Name  | Type                                                                  | Mandatory| Description                     |
192| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
193| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md)                      | Yes  | Context of the ability instance.|
194| asset | [PhotoAsset](arkts-apis-photoAccessHelper-PhotoAsset.md)                                            | Yes  | Image to request.|
195| requestOptions  | [RequestOptions](arkts-apis-photoAccessHelper-i.md#requestoptions11)                                  | Yes  | Options for requesting the image.|
196| dataHandler  | [MediaAssetDataHandler](arkts-apis-photoAccessHelper-MediaAssetDataHandler.md)&lt;[MovingPhoto](arkts-apis-photoAccessHelper-MovingPhoto.md)&gt; | Yes  | Media asset handler, which invokes a callback to return the image when the requested image is ready.|
197
198**Return value**
199
200| Type                                   | Description             |
201| --------------------------------------- | ----------------- |
202| Promise\<string> | Promise used to return the request ID, which can be used in [cancelRequest](#cancelrequest12) to cancel a request.|
203
204**Error codes**
205
206For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
207
208| ID| Error Message|
209| -------- | ---------------------------------------- |
210| 201      |  Permission denied         |
211| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
212| 801   | Capability not supported.       |
213| 14000011       | System inner fail         |
214
215**Example**
216
217For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
218
219```ts
220import { dataSharePredicates } from '@kit.ArkData';
221
222class MovingPhotoHandler implements photoAccessHelper.MediaAssetDataHandler<photoAccessHelper.MovingPhoto> {
223  async onDataPrepared(movingPhoto: photoAccessHelper.MovingPhoto) {
224    if (movingPhoto === undefined) {
225      console.error('Error occurred when preparing data');
226      return;
227    }
228    console.info("moving photo acquired successfully, uri: " + movingPhoto.getUri());
229  }
230}
231
232async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper, context: Context) {
233  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
234  predicates.equalTo(photoAccessHelper.PhotoKeys.PHOTO_SUBTYPE, photoAccessHelper.PhotoSubtype.MOVING_PHOTO);
235  let fetchOptions: photoAccessHelper.FetchOptions = {
236    fetchColumns: [],
237    predicates: predicates
238  };
239  // Ensure that there are moving photos in Gallery.
240  let assetResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = await phAccessHelper.getAssets(fetchOptions);
241  let asset: photoAccessHelper.PhotoAsset = await assetResult.getFirstObject();
242  let requestOptions: photoAccessHelper.RequestOptions = {
243    deliveryMode: photoAccessHelper.DeliveryMode.FAST_MODE,
244  }
245  const handler = new MovingPhotoHandler();
246  try {
247    let requestId: string = await photoAccessHelper.MediaAssetManager.requestMovingPhoto(context, asset, requestOptions, handler);
248    console.info("moving photo requested successfully, requestId: " + requestId);
249  } catch (err) {
250    console.error(`failed to request moving photo, error code is ${err.code}, message is ${err.message}`);
251  }
252}
253
254```
255
256## requestVideoFile<sup>12+</sup>
257
258static requestVideoFile(context: Context, asset: PhotoAsset, requestOptions: RequestOptions, fileUri: string, dataHandler: MediaAssetDataHandler&lt;boolean&gt;): Promise&lt;string&gt;
259
260Requests a video and saves it to the specified sandbox directory.
261
262**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
263
264**Required permissions**: ohos.permission.READ_IMAGEVIDEO
265
266- When you call this API in Picker mode, you do not need to request the ohos.permission.READ_IMAGEVIDEO permission. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
267- For the videos saved to the media library by this application, the application can access them without the ohos.permission.READ_IMAGEVIDEO permission.
268
269**Parameters**
270
271| Name  | Type                                                                  | Mandatory| Description                     |
272| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
273| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md)                      | Yes  | Context of the ability instance.|
274| asset | [PhotoAsset](arkts-apis-photoAccessHelper-PhotoAsset.md)                                            | Yes  | Image to request.|
275| requestOptions  | [RequestOptions](arkts-apis-photoAccessHelper-i.md#requestoptions11)                                  | Yes  | Options for requesting the video asset.|
276| fileUri| string                                                              | Yes| URI of the sandbox directory, to which the requested video asset is to be saved. Example: **'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.mp4'**.|
277| dataHandler  | [MediaAssetDataHandler](arkts-apis-photoAccessHelper-MediaAssetDataHandler.md)&lt;boolean&gt; | Yes  | Media asset handler. When the requested video is written to the specified directory, a callback is triggered.<br>If the video is successfully written, **true** is returned. Otherwise, **false** is returned.|
278
279**Return value**
280
281| Type                                   | Description             |
282| --------------------------------------- | ----------------- |
283| Promise\<string> | Promise used to return the request ID, which can be used in [cancelRequest](#cancelrequest12) to cancel a request.|
284
285**Error codes**
286
287For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
288
289| ID| Error Message|
290| -------- | ---------------------------------------- |
291| 201      |  Permission denied         |
292| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
293| 801<sup>15+</sup>   | Capability not supported.       |
294| 14000011       | System inner fail.        |
295
296**Example**
297
298For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
299
300```ts
301import { dataSharePredicates } from '@kit.ArkData';
302
303class MediaDataHandler implements photoAccessHelper.MediaAssetDataHandler<boolean> {
304    onDataPrepared(data: boolean) {
305        console.info('on video request status prepared');
306    }
307}
308
309async function example(phAccessHelper: photoAccessHelper.PhotoAccessHelper, context: Context) {
310  console.info('requestVideoFile');
311  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
312  let fetchOptions: photoAccessHelper.FetchOptions = {
313    fetchColumns: [],
314    predicates: predicates
315  };
316  let requestOptions: photoAccessHelper.RequestOptions = {
317    deliveryMode: photoAccessHelper.DeliveryMode.HIGH_QUALITY_MODE,
318  }
319  const handler = new MediaDataHandler();
320  let fileUri = 'file://com.example.temptest/data/storage/el2/base/haps/entry/files/test.mp4';
321  phAccessHelper.getAssets(fetchOptions, async (err, fetchResult) => {
322      console.info('fetchResult success');
323      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
324      await photoAccessHelper.MediaAssetManager.requestVideoFile(context, photoAsset, requestOptions, fileUri, handler);
325      console.info('requestVideoFile successfully');
326  });
327}
328```
329
330## cancelRequest<sup>12+</sup>
331
332static cancelRequest(context: Context, requestId: string): Promise\<void>
333
334Cancels a request for the asset, the callback of which has not been triggered yet.
335
336**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
337
338**Required permissions**: ohos.permission.READ_IMAGEVIDEO
339
340**Parameters**
341
342| Name  | Type                                                                  | Mandatory| Description                     |
343| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
344| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md)                      | Yes  | Context of the ability instance.|
345| requestId | string     | Yes  | ID of the request to cancel. It is a valid request ID returned by **requestImage**.|
346
347**Return value**
348
349| Type                                   | Description             |
350| --------------------------------------- | ----------------- |
351| Promise\<void> | Promise that returns no value.|
352
353**Error codes**
354
355For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
356
357| ID| Error Message|
358| -------- | ---------------------------------------- |
359| 201      |  Permission denied         |
360| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
361| 14000011       | System inner fail         |
362
363**Example**
364
365```ts
366import { dataSharePredicates } from '@kit.ArkData';
367
368async function example(context: Context) {
369  try {
370    let requestId: string = 'xxx-xxx'; // A valid requestId returned by APIs such as requestImage() must be used.
371    await photoAccessHelper.MediaAssetManager.cancelRequest(context, requestId);
372    console.info("request cancelled successfully");
373  } catch (err) {
374    console.error(`cancelRequest failed with error: ${err.code}, ${err.message}`);
375  }
376}
377
378```
379
380## loadMovingPhoto<sup>12+</sup>
381
382static loadMovingPhoto(context: Context, imageFileUri: string, videoFileUri: string): Promise\<MovingPhoto>
383
384Loads a moving photo in the application sandbox.
385
386**Atomic service API**: This API can be used in atomic services since API version 14.
387
388**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
389
390**Parameters**
391
392| Name  | Type                                                                  | Mandatory| Description                     |
393| -------- |----------------------------------------------------------------------| ---- | ------------------------- |
394| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md)   | Yes  | AbilityContext or UIExtensionContext instance.|
395| imageFileUri | string     | Yes  | URI of the image file of the moving photo in the application sandbox.<br>Example: **'file://com.example.temptest/data/storage/el2/base/haps/ImageFile.jpg'**.|
396| videoFileUri | string     | Yes  | URI of the video file of the moving photo in the application sandbox.<br>Example: **'file://com.example.temptest/data/storage/el2/base/haps/VideoFile.mp4'**.|
397
398**Return value**
399
400| Type                                   | Description             |
401| --------------------------------------- | ----------------- |
402| Promise\<MovingPhoto> | Promise used to return the [MovingPhoto](arkts-apis-photoAccessHelper-MovingPhoto.md) instance.|
403
404**Error codes**
405
406For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
407
408| ID| Error Message|
409| -------- | ---------------------------------------- |
410| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
411| 14000011 | Internal system error. |
412
413**Example**
414
415```ts
416async function example(context: Context) {
417  try {
418    let imageFileUri: string = 'file://com.example.temptest/data/storage/el2/base/haps/ImageFile.jpg'; // URI of the image file of the moving photo in the application sandbox.
419    let videoFileUri: string = 'file://com.example.temptest/data/storage/el2/base/haps/VideoFile.mp4'; // URI of the video file of the moving photo in the application sandbox.
420    let movingPhoto: photoAccessHelper.MovingPhoto = await photoAccessHelper.MediaAssetManager.loadMovingPhoto(context, imageFileUri, videoFileUri);
421  } catch (err) {
422    console.error(`loadMovingPhoto failed with error: ${err.code}, ${err.message}`);
423  }
424}
425
426```
427
428## quickRequestImage<sup>13+</sup>
429
430static quickRequestImage(context: Context, asset: PhotoAsset, requestOptions: RequestOptions, dataHandler: QuickImageDataHandler&lt;image.Picture&gt;): Promise&lt;string&gt;
431
432Requests an image quickly.
433
434**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
435
436**Required permissions**: ohos.permission.READ_IMAGEVIDEO
437
438- When you call this API in Picker mode, you do not need to request the ohos.permission.READ_IMAGEVIDEO permission. For details, see [Obtaining an Image or Video by URI](../../media/medialibrary/photoAccessHelper-photoviewpicker.md#obtaining-an-image-or-video-by-uri).
439
440**Parameters**
441
442| Name           | Type                                                                                                       | Mandatory| Description                     |
443|----------------|-----------------------------------------------------------------------------------------------------------| ---- | ------------------------- |
444| context        | [Context](../apis-ability-kit/js-apis-inner-application-context.md)                                                           | Yes  | Context of the ability instance.|
445| asset         | [PhotoAsset](arkts-apis-photoAccessHelper-PhotoAsset.md)                                                                                | Yes  | Image to request.|
446| requestOptions | [RequestOptions](arkts-apis-photoAccessHelper-i.md#requestoptions11)                                                                        | Yes  | Options for requesting the image.|
447| dataHandler    | [QuickImageDataHandler](arkts-apis-photoAccessHelper-QuickImageDataHandler.md)&lt;[image.Picture](../apis-image-kit/arkts-apis-image-Picture.md)&gt; | Yes  | Media asset handler, which invokes a callback to return the image when the requested image is ready.|
448
449**Return value**
450
451| Type                                   | Description             |
452| --------------------------------------- | ----------------- |
453| Promise\<string> | Promise used to return the request ID, which can be used in [cancelRequest](#cancelrequest12) to cancel a request.|
454
455**Error codes**
456
457For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [File Management Error Codes](../apis-core-file-kit/errorcode-filemanagement.md).
458
459| ID| Error Message|
460| -------- | ---------------------------------------- |
461| 201      |  Permission denied         |
462| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
463| 14000011       | Internal system error.         |
464
465**Example**
466
467For details about how to create a phAccessHelper instance, see the example provided in [photoAccessHelper.getPhotoAccessHelper](arkts-apis-photoAccessHelper-f.md#photoaccesshelpergetphotoaccesshelper).
468
469```ts
470import { dataSharePredicates } from '@kit.ArkData';
471import { image } from '@kit.ImageKit';
472
473class MediaHandler implements photoAccessHelper.QuickImageDataHandler<image.Picture> {
474  onDataPrepared(data: image.Picture, imageSource: image.ImageSource, map: Map<string, string>) {
475    console.info('on image data prepared');
476  }
477}
478
479async function example(context: Context) {
480  console.info('quickRequestImage');
481  let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
482  let fetchOptions: photoAccessHelper.FetchOptions = {
483    fetchColumns: [],
484    predicates: predicates
485  };
486  let requestOptions: photoAccessHelper.RequestOptions = {
487    deliveryMode: photoAccessHelper.DeliveryMode.HIGH_QUALITY_MODE,
488  }
489  const handler = new MediaHandler();
490  let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
491  phAccessHelper.getAssets(fetchOptions, async (err, fetchResult) => {
492      console.info('fetchResult success');
493      let photoAsset: photoAccessHelper.PhotoAsset = await fetchResult.getFirstObject();
494      await photoAccessHelper.MediaAssetManager.quickRequestImage(context, photoAsset, requestOptions, handler);
495      console.info('quickRequestImage successfully');
496  });
497}
498```
499