• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.file.picker (File Picker)
2
3**Picker** encapsulates the system applications such as **PhotoViewPicker**, **DocumentViewPicker** and **AudioViewPicker** to provide capabilities of selecting and saving files of different types. The application can select the picker as required.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
9## Modules to Import
10```js
11import picker from '@ohos.file.picker';
12```
13
14## PhotoViewPicker
15
16Provides APIs for selecting and saving images and videos. Before using the APIs of **PhotoViewPicker**, you need to create a **PhotoViewPicker** instance.
17
18**System capability**: SystemCapability.FileManagement.UserFileService
19
20**Example**
21
22```ts
23let photoPicker = new picker.PhotoViewPicker();
24```
25
26### select
27
28select(option?: PhotoSelectOptions) : Promise<PhotoSelectResult>
29
30Selects one or more images or videos in a **photoPicker** page. This API uses a promise to return the result. You can pass in **PhotoSelectOptions** to specify the media file type and the maximum number of files to select.
31
32**System capability**: SystemCapability.FileManagement.UserFileService
33
34**Parameters**
35
36| Name | Type   | Mandatory| Description                      |
37| ------- | ------- | ---- | -------------------------- |
38| option | [PhotoSelectOptions](#photoselectoptions) | No  | Options for selecting files. If this parameter is not specified, images and videos are selected by default. A maximum of 50 files can be selected.|
39
40**Return value**
41
42| Type                           | Description   |
43| ----------------------------- | :---- |
44| Promise<[PhotoSelectResult](#photoselectresult)> | Promise used to return information about the images or videos selected.|
45
46**Example**
47
48```ts
49async function example() {
50  try {
51    let PhotoSelectOptions = new picker.PhotoSelectOptions();
52    PhotoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE;
53    PhotoSelectOptions.maxSelectNumber = 5;
54    let photoPicker = new picker.PhotoViewPicker();
55    photoPicker.select(PhotoSelectOptions).then((PhotoSelectResult) => {
56      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
57    }).catch((err) => {
58      console.error('PhotoViewPicker.select failed with err: ' + err);
59    });
60  } catch (err) {
61    console.error('PhotoViewPicker failed with err: ' + err);
62  }
63}
64```
65
66### select
67
68select(option: PhotoSelectOptions, callback: AsyncCallback<PhotoSelectResult>) : void
69
70Selects one or more images or videos in a **photoPicker** page. This API uses an asynchronous callback to return the result. You can pass in **PhotoSelectOptions** to specify the media file type and the maximum number of files to select.
71
72**System capability**: SystemCapability.FileManagement.UserFileService
73
74**Parameters**
75
76| Name | Type   | Mandatory| Description                      |
77| ------- | ------- | ---- | -------------------------- |
78| option | [PhotoSelectOptions](#photoselectoptions) | Yes  | Options for selecting images or videos.|
79| callback | AsyncCallback<[PhotoSelectResult](#photoselectresult)>      | Yes  | Callback invoked to return information about the images or videos selected.|
80
81**Example**
82
83```ts
84async function example() {
85  try {
86    let PhotoSelectOptions = new picker.PhotoSelectOptions();
87    PhotoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE;
88    PhotoSelectOptions.maxSelectNumber = 5;
89    let photoPicker = new picker.PhotoViewPicker();
90    photoPicker.select(PhotoSelectOptions, (err, PhotoSelectResult) => {
91      if (err) {
92        console.error('PhotoViewPicker.select failed with err: ' + err);
93        return;
94      }
95      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
96    });
97  } catch (err) {
98    console.error('PhotoViewPicker failed with err: ' + err);
99  }
100}
101```
102
103### select
104
105select(callback: AsyncCallback<PhotoSelectResult>) : void
106
107Selects one or more images or videos in a **photoPicker** page. This API uses an asynchronous callback to return the result.
108
109**System capability**: SystemCapability.FileManagement.UserFileService
110
111**Parameters**
112
113| Name | Type   | Mandatory| Description                      |
114| ------- | ------- | ---- | -------------------------- |
115| callback | AsyncCallback<[PhotoSelectResult](#photoselectresult)>      | Yes  | Callback invoked to return information about the images or videos selected.|
116
117**Example**
118
119```ts
120async function example() {
121  try {
122    let photoPicker = new picker.PhotoViewPicker();
123    photoPicker.select((err, PhotoSelectResult) => {
124      if (err) {
125        console.error('PhotoViewPicker.select failed with err: ' + err);
126        return;
127      }
128      console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
129    });
130  } catch (err) {
131    console.error('PhotoViewPicker failed with err: ' + err);
132  }
133}
134```
135
136### save
137
138save(option?: PhotoSaveOptions) : Promise<Array<string>>
139
140Saves one or more images or videos in a **photoPicker** page. This API uses a promise to return the result. You can pass in **PhotoSaveOptions** to specify the file names of the images or videos to save.
141
142**System capability**: SystemCapability.FileManagement.UserFileService
143
144**Parameters**
145
146| Name | Type   | Mandatory| Description                      |
147| ------- | ------- | ---- | -------------------------- |
148| option | [PhotoSaveOptions](#photosaveoptions) | No  | Options for saving files. If this parameter is not specified, a **photoPicker** page will be displayed for the user to enter the names of the files to save.|
149
150**Return value**
151
152| Type                           | Description   |
153| ----------------------------- | :---- |
154| Promise<Array<string>> | Promise used to return the URIs of the files saved.|
155
156**Example**
157
158```ts
159async function example() {
160  try {
161    let PhotoSaveOptions = new picker.PhotoSaveOptions();
162    PhotoSaveOptions.newFileNames = ['PhotoViewPicker01.jpg', 'PhotoViewPicker01.mp4'];
163    let photoPicker = new picker.PhotoViewPicker();
164    photoPicker.save(PhotoSaveOptions).then((PhotoSaveResult) => {
165      console.info('PhotoViewPicker.save successfully, PhotoSaveResult uri: ' + JSON.stringify(PhotoSaveResult));
166    }).catch((err) => {
167      console.error('PhotoViewPicker.save failed with err: ' + err);
168    });
169  } catch (err) {
170      console.error('PhotoViewPicker failed with err: ' + err);
171  }
172}
173```
174
175### save
176
177save(option: PhotoSaveOptions, callback: AsyncCallback<Array<string>>) : void
178
179Saves one or more images or videos in a **photoPicker** page. This API uses an asynchronous callback to return the result. You can pass in **PhotoSaveOptions** to specify the file names of the images or videos to save.
180
181**System capability**: SystemCapability.FileManagement.UserFileService
182
183**Parameters**
184
185| Name | Type   | Mandatory| Description                      |
186| ------- | ------- | ---- | -------------------------- |
187| option | [PhotoSaveOptions](#photosaveoptions) | Yes  | Options for saving images or videos.|
188| callback | AsyncCallback<Array<string>>      | Yes  | Callback invoked to return the URIs of the files saved.|
189
190**Example**
191
192```ts
193async function example() {
194  try {
195    let PhotoSaveOptions = new picker.PhotoSaveOptions();
196    PhotoSaveOptions.newFileNames = ['PhotoViewPicker02.jpg','PhotoViewPicker02.mp4'];
197    let photoPicker = new picker.PhotoViewPicker();
198    photoPicker.save(PhotoSaveOptions, (err, PhotoSaveResult) => {
199      if (err) {
200        console.error('PhotoViewPicker.save failed with err: ' + err);
201        return;
202      }
203      console.info('PhotoViewPicker.save successfully, PhotoSaveResult uri: ' + JSON.stringify(PhotoSaveResult));
204    });
205  } catch (err) {
206    console.error('PhotoViewPicker failed with err: ' + err);
207  }
208}
209```
210
211### save
212
213save(callback: AsyncCallback<Array<string>>) : void
214
215Saves one or more images or videos in a **photoPicker** page. This API uses an asynchronous callback to return the result.
216
217**System capability**: SystemCapability.FileManagement.UserFileService
218
219**Parameters**
220
221| Name | Type   | Mandatory| Description                      |
222| ------- | ------- | ---- | -------------------------- |
223| callback | AsyncCallback<Array<string>>      | Yes  | Callback invoked to return the URIs of the files saved.|
224
225**Example**
226
227```ts
228async function example() {
229  try {
230    let photoPicker = new picker.PhotoViewPicker();
231    photoPicker.save((err, PhotoSaveResult) => {
232      if (err) {
233        console.error('PhotoViewPicker.save failed with err: ' + err);
234        return;
235      }
236      console.info('PhotoViewPicker.save successfully, PhotoSaveResult uri: ' + JSON.stringify(PhotoSaveResult));
237    });
238  } catch (err) {
239    console.error('PhotoViewPicker failed with err: ' + err);
240  }
241}
242```
243
244## DocumentViewPicker
245
246Provides APIs for selecting and saving non-media files, for example, documents in a variety of formats. Before using the APIs of **DocumentViewPicker**, you need to create a **DocumentViewPicker** instance.
247
248**System capability**: SystemCapability.FileManagement.UserFileService
249
250**Example**
251
252```ts
253let documentPicker = new picker.DocumentViewPicker();
254```
255
256### select
257
258select(option?: DocumentSelectOptions) : Promise<Array<string>>
259
260Selects one or more documents in a **documentPicker** page. This API uses a promise to return the result. You can pass in **DocumentSelectOptions**.
261
262**System capability**: SystemCapability.FileManagement.UserFileService
263
264**Parameters**
265
266| Name | Type   | Mandatory| Description                      |
267| ------- | ------- | ---- | -------------------------- |
268| option | [DocumentSelectOptions](#documentselectoptions) | No  | Options for select documents. If this parameter is not specified, the **documentPicker** page is displayed by default.|
269
270**Return value**
271
272| Type                           | Description   |
273| ----------------------------- | :---- |
274| Promise<Array<string>> | Promise used to return the URIs of the documents selected.|
275
276**Example**
277
278```ts
279async function example() {
280  try {
281    let DocumentSelectOptions = new picker.DocumentSelectOptions();
282    let documentPicker = new picker.DocumentViewPicker();
283    documentPicker.select(DocumentSelectOptions).then((DocumentSelectResult) => {
284      console.info('DocumentViewPicker.select successfully, DocumentSelectResult uri: ' + JSON.stringify(DocumentSelectResult));
285    }).catch((err) => {
286      console.error('DocumentViewPicker.select failed with err: ' + err);
287    });
288  } catch (err) {
289    console.error('DocumentViewPicker failed with err: ' + err);
290  }
291}
292```
293
294### select
295
296select(option: DocumentSelectOptions, callback: AsyncCallback<Array<string>>) : void
297
298Selects one or more documents in a **documentPicker** page. This API uses an asynchronous callback to return the result. You can pass in **DocumentSelectOptions**.
299
300**System capability**: SystemCapability.FileManagement.UserFileService
301
302**Parameters**
303
304| Name | Type   | Mandatory| Description                      |
305| ------- | ------- | ---- | -------------------------- |
306| option | [DocumentSelectOptions](#documentselectoptions) | Yes  | Options for selecting documents.|
307| callback | AsyncCallback<Array<string>>      | Yes  | Callback invoked to return the URIs of the documents selected.|
308
309**Example**
310
311```ts
312async function example() {
313  try {
314    let DocumentSelectOptions = new picker.DocumentSelectOptions();
315    let documentPicker = new picker.DocumentViewPicker();
316    documentPicker.select(DocumentSelectOptions, (err, DocumentSelectResult) => {
317      if (err) {
318        console.error('DocumentViewPicker.select failed with err: ' + err);
319        return;
320      }
321      console.info('DocumentViewPicker.select successfully, DocumentSelectResult uri: ' + JSON.stringify(DocumentSelectResult));
322    });
323  } catch (err) {
324    console.error('DocumentViewPicker failed with err: ' + err);
325  }
326}
327```
328
329### select
330
331select(callback: AsyncCallback<Array<string>>) : void
332
333Selects one or more documents in a **documentPicker** page. This API uses an asynchronous callback to return the result.
334
335**System capability**: SystemCapability.FileManagement.UserFileService
336
337**Parameters**
338
339| Name | Type   | Mandatory| Description                      |
340| ------- | ------- | ---- | -------------------------- |
341| callback | AsyncCallback<Array<string>>      | Yes  | Callback invoked to return the URIs of the documents selected.|
342
343**Example**
344
345```ts
346async function example() {
347  try {
348    let documentPicker = new picker.DocumentViewPicker();
349    documentPicker.select((err, DocumentSelectResult) => {
350      if (err) {
351        console.error('DocumentViewPicker.select failed with err: ' + err);
352        return;
353      }
354      console.info('DocumentViewPicker.select successfully, DocumentSelectResult uri: ' + JSON.stringify(DocumentSelectResult));
355    });
356  } catch (err) {
357    console.error('DocumentViewPicker failed with err: ' + err);
358  }
359}
360```
361
362
363### save
364
365save(option?: DocumentSaveOptions) : Promise<Array<string>>
366
367Saves one or more documents in a **documentPicker** page. This API uses a promise to return the result. You can pass in **DocumentSaveOptions** to specify the file names to save.
368
369**System capability**: SystemCapability.FileManagement.UserFileService
370
371**Parameters**
372
373| Name | Type   | Mandatory| Description                      |
374| ------- | ------- | ---- | -------------------------- |
375| option | [DocumentSaveOptions](#documentsaveoptions) | No  | Options for saving the documents. If this parameter is not specified, a **documentPicker** page will be displayed for the user to enter the names of the documents to save.|
376
377**Return value**
378
379| Type                           | Description   |
380| ----------------------------- | :---- |
381| Promise<Array<string>> | Promise used to return the URIs of the documents saved.|
382
383**Example**
384
385```ts
386async function example() {
387  try {
388    let DocumentSaveOptions = new picker.DocumentSaveOptions();
389    DocumentSaveOptions.newFileNames = ['DocumentViewPicker01.txt'];
390    let documentPicker = new picker.DocumentViewPicker();
391    documentPicker.save(DocumentSaveOptions).then((DocumentSaveResult) => {
392      console.info('DocumentViewPicker.save successfully, DocumentSaveResult uri: ' + JSON.stringify(DocumentSaveResult));
393    }).catch((err) => {
394      console.error('DocumentViewPicker.save failed with err: ' + err);
395    });
396  } catch (err) {
397    console.error('DocumentViewPicker failed with err: ' + err);
398  }
399}
400```
401
402### save
403
404save(option: DocumentSaveOptions, callback: AsyncCallback<Array<string>>) : void
405
406Saves one or more documents in a **documentPicker** page. This API uses an asynchronous callback to return the result. You can pass in **DocumentSaveOptions** to specify the file names to save.
407
408**System capability**: SystemCapability.FileManagement.UserFileService
409
410**Parameters**
411
412| Name | Type   | Mandatory| Description                      |
413| ------- | ------- | ---- | -------------------------- |
414| option | [DocumentSaveOptions](#documentsaveoptions) | Yes  | Options for saving the documents.|
415| callback | AsyncCallback<Array<string>>      | Yes  | Callback invoked to return the URIs of the documents saved.|
416
417**Example**
418
419```ts
420async function example() {
421  try {
422    let DocumentSaveOptions = new picker.DocumentSaveOptions();
423    DocumentSaveOptions.newFileNames = ['DocumentViewPicker02.txt'];
424    let documentPicker = new picker.DocumentViewPicker();
425    documentPicker.save(DocumentSaveOptions, (err, DocumentSaveResult) => {
426      if (err) {
427        console.error('DocumentViewPicker.save failed with err: ' + err);
428        return;
429      }
430      console.info('DocumentViewPicker.save successfully, DocumentSaveResult uri: ' + JSON.stringify(DocumentSaveResult));
431    });
432  } catch (err) {
433    console.error('DocumentViewPicker failed with err: ' + err);
434  }
435}
436```
437
438### save
439
440save(callback: AsyncCallback<Array<string>>) : void
441
442Saves one or more documents in a **documentPicker** page. This API uses an asynchronous callback to return the result.
443
444**System capability**: SystemCapability.FileManagement.UserFileService
445
446**Parameters**
447
448| Name | Type   | Mandatory| Description                      |
449| ------- | ------- | ---- | -------------------------- |
450| callback | AsyncCallback<Array<string>>      | Yes  | Callback invoked to return the URIs of the documents saved.|
451
452**Example**
453
454```ts
455async function example() {
456  try {
457    let documentPicker = new picker.DocumentViewPicker();
458    documentPicker.save((err, DocumentSaveResult) => {
459      if (err) {
460        console.error('DocumentViewPicker.save failed with err: ' + err);
461        return;
462      }
463      console.info('DocumentViewPicker.save successfully, DocumentSaveResult uri: ' + JSON.stringify(DocumentSaveResult));
464    });
465  } catch (err) {
466    console.error('DocumentViewPicker failed with err: ' + err);
467  }
468}
469```
470
471## AudioViewPicker
472
473Provides APIs for selecting and saving audio files. Before using the APIs of **AudioViewPicker**, you need to create an **AudioViewPicker** instance.
474
475**System capability**: SystemCapability.FileManagement.UserFileService
476
477**Example**
478
479```ts
480let audioPicker = new picker.AudioViewPicker();
481```
482
483### select
484
485select(option?: AudioSelectOptions) : Promise<Array<string>>
486
487Selects one or more audio files in an **audioPicker** page (currently, a **documentPicker** page is displayed). This API uses a promise to return the result. You can pass in **AudioSelectOptions**.
488
489**System capability**: SystemCapability.FileManagement.UserFileService
490
491**Parameters**
492
493| Name | Type   | Mandatory| Description                      |
494| ------- | ------- | ---- | -------------------------- |
495| option | [AudioSelectOptions](#audioselectoptions) | No  | Options for selecting the audio files. If this parameter is not specified, the **audioPicker** page is displayed by default. |
496
497**Return value**
498
499| Type                           | Description   |
500| ----------------------------- | :---- |
501| Promise<Array<string>> | Promise used to return the URIs of the audio files selected.|
502
503**Example**
504
505```ts
506async function example() {
507  try {
508    let AudioSelectOptions = new picker.AudioSelectOptions();
509    let audioPicker = new picker.AudioViewPicker();
510    audioPicker.select(AudioSelectOptions).then((AudioSelectResult) => {
511      console.info('AudioViewPicker.select successfully, AudioSelectResult uri: ' + JSON.stringify(AudioSelectResult));
512    }).catch((err) => {
513      console.error('AudioViewPicker.select failed with err: ' + err);
514    });
515  } catch (err) {
516    console.error('AudioViewPicker failed with err: ' + err);
517  }
518}
519```
520
521### select
522
523select(option: AudioSelectOptions, callback: AsyncCallback<Array<string>>) : void
524
525Selects one or more audio files in an **audioPicker** page (currently, a **documentPicker** page is displayed). This API uses an asynchronous callback to return the result. You can pass in **AudioSelectOptions**.
526
527**System capability**: SystemCapability.FileManagement.UserFileService
528
529**Parameters**
530
531| Name | Type   | Mandatory| Description                      |
532| ------- | ------- | ---- | -------------------------- |
533| option | [AudioSelectOptions](#audioselectoptions) | Yes  | Options for selecting audio files.|
534| callback | AsyncCallback<Array<string>>      | Yes  | Callback invoked to return the URIs of the audio files selected.|
535
536**Example**
537
538```ts
539async function example() {
540  try {
541    let AudioSelectOptions = new picker.AudioSelectOptions();
542    let audioPicker = new picker.AudioViewPicker();
543    audioPicker.select(AudioSelectOptions, (err, AudioSelectResult) => {
544      if (err) {
545        console.error('AudioViewPicker.select failed with err: ' + err);
546        return;
547      }
548      console.info('AudioViewPicker.select successfully, AudioSelectResult uri: ' + JSON.stringify(AudioSelectResult));
549    });
550  } catch (err) {
551    console.error('AudioViewPicker failed with err: ' + err);
552  }
553}
554```
555
556### select
557
558select(callback: AsyncCallback<Array<string>>) : void
559
560Selects one or more audio files in an **audioPicker** page (currently, a **documentPicker** page is displayed). This API uses an asynchronous callback to return the result.
561
562**System capability**: SystemCapability.FileManagement.UserFileService
563
564**Parameters**
565
566| Name | Type   | Mandatory| Description                      |
567| ------- | ------- | ---- | -------------------------- |
568| callback | AsyncCallback<Array<string>>      | Yes  | Callback invoked to return the URIs of the audio files selected.|
569
570**Example**
571
572```ts
573async function example() {
574  try {
575    let audioPicker = new picker.AudioViewPicker();
576    audioPicker.select((err, AudioSelectResult) => {
577      if (err) {
578        console.error('AudioViewPicker.select failed with err: ' + err);
579        return;
580      }
581      console.info('AudioViewPicker.select successfully, AudioSelectResult uri: ' + JSON.stringify(AudioSelectResult));
582    });
583  } catch (err) {
584    console.error('AudioViewPicker failed with err: ' + err);
585  }
586}
587```
588
589### save
590
591save(option?: AudioSaveOptions) : Promise<Array<string>>
592
593Saves one or more audio files in an **audioPicker** page (currently, a **documentPicker** page is displayed). This API uses a promise to return the result. You can pass in **AudioSaveOptions** to specify the names of the audio files to save.
594
595**System capability**: SystemCapability.FileManagement.UserFileService
596
597**Parameters**
598
599| Name | Type   | Mandatory| Description                      |
600| ------- | ------- | ---- | -------------------------- |
601| option | [AudioSaveOptions](#audiosaveoptions) | No  | Options for saving audio files. If this parameter is not specified, an **audioPicker** page will be displayed for the user to enter the names of the files to save.|
602
603**Return value**
604
605| Type                           | Description   |
606| ----------------------------- | ---- |
607| Promise<Array<string>> | Promise used to return the URIs of the audio files saved.|
608
609**Example**
610
611```ts
612async function example() {
613  try {
614    let AudioSaveOptions = new picker.AudioSaveOptions();
615    AudioSaveOptions.newFileNames = ['AudioViewPicker01.mp3'];
616    let audioPicker = new picker.AudioViewPicker();
617    audioPicker.save(AudioSaveOptions).then((AudioSaveResult) => {
618      console.info('AudioViewPicker.save successfully, AudioSaveResult uri: ' + JSON.stringify(AudioSaveResult))
619    }).catch((err) => {
620      console.error('AudioViewPicker.save failed with err: ' + err);
621    });
622  } catch (err) {
623    console.error('AudioViewPicker failed with err: ' + err);
624  }
625}
626```
627
628### save
629
630save(option: AudioSaveOptions, callback: AsyncCallback<Array<string>>) : void
631
632Saves one or more audio files in an **audioPicker** page (currently, a **documentPicker** page is displayed). This API uses an asynchronous callback to return the result. You can pass in **AudioSaveOptions** to specify the names of the audio files to save.
633
634**System capability**: SystemCapability.FileManagement.UserFileService
635
636**Parameters**
637
638| Name | Type   | Mandatory| Description                      |
639| ------- | ------- | ---- | -------------------------- |
640| option | [AudioSaveOptions](#audiosaveoptions) | Yes  | Options for saving audio files.|
641| callback | AsyncCallback<Array<string>>      | Yes  | Callback invoked to return the URIs of the audio files saved.|
642
643**Example**
644
645```ts
646async function example() {
647  try {
648    let AudioSaveOptions = new picker.AudioSaveOptions();
649    AudioSaveOptions.newFileNames = ['AudioViewPicker02.mp3'];
650    let audioPicker = new picker.AudioViewPicker();
651    audioPicker.save(AudioSaveOptions, (err, AudioSaveResult) => {
652      if (err) {
653        console.error('AudioViewPicker.save failed with err: ' + err);
654        return;
655      }
656      console.info('AudioViewPicker.save successfully, AudioSaveResult uri: ' + JSON.stringify(AudioSaveResult));
657    });
658  } catch (err) {
659    console.error('AudioViewPicker failed with err: ' + err);
660  }
661}
662```
663
664### save
665
666save(callback: AsyncCallback<Array<string>>) : void
667
668Saves one or more audio files in an **audioPicker** page (currently, a **documentPicker** page is displayed). This API uses an asynchronous callback to return the result.
669
670**System capability**: SystemCapability.FileManagement.UserFileService
671
672**Parameters**
673
674| Name | Type   | Mandatory| Description                      |
675| ------- | ------- | ---- | -------------------------- |
676| callback | AsyncCallback<Array<string>>      | Yes  | Callback invoked to return the URIs of the audio files saved.|
677
678**Example**
679
680```ts
681async function example() {
682  try {
683    let audioPicker = new picker.AudioViewPicker();
684    audioPicker.save((err, AudioSaveResult) => {
685      if (err) {
686        console.error('AudioViewPicker.save failed with err: ' + err);
687        return;
688      }
689      console.info('AudioViewPicker.save successfully, AudioSaveResult uri: ' + JSON.stringify(AudioSaveResult));
690    });
691  } catch (err) {
692    console.error('AudioViewPicker failed with err: ' + err);
693  }
694}
695```
696
697## PhotoViewMIMETypes
698
699Enumerates the media file types that can be selected.
700
701**System capability**: SystemCapability.FileManagement.UserFileService
702
703| Name |  Value|  Description|
704| ----- |  ---- | ---- |
705| IMAGE_TYPE  |  'image/*' | Image.|
706| VIDEO_TYPE |  'video/*' | Video.|
707| IMAGE_VIDEO_TYPE |  '\*/*' | Image and video.|
708
709## PhotoSelectOptions
710
711Defines the options for selecting images or videos.
712
713**System capability**: SystemCapability.FileManagement.UserFileService
714
715| Name                   | Type               | Mandatory| Description                         |
716| ----------------------- | ------------------- | ---- | -------------------------------- |
717| MIMEType?              | [PhotoViewMIMETypes](#photoviewmimetypes)   | No  | Available media file types. **IMAGE_VIDEO_TYPE** is used by default.|
718| maxSelectNumber?       | number | No  | Maximum number of media files to select. The default value is **50**, and the maximum value is **500**.     |
719
720## PhotoSelectResult
721
722Defines information about the images or videos selected.
723
724**System capability**: SystemCapability.FileManagement.UserFileService
725
726| Name                   | Type               | Readable| Writable| Description                          |
727| ----------------------- | ------------------- | ---- | ---- | ------------------------------ |
728| photoUris        | Array<string>    | Yes  | Yes  | URIs of the media files selected.|
729| isOriginalPhoto        | boolean    | Yes  | Yes  | Whether the selected media file is the original image.|
730
731## PhotoSaveOptions
732
733Defines the options for saving images or videos.
734
735**System capability**: SystemCapability.FileManagement.UserFileService
736
737| Name                   | Type               | Mandatory|  Description                          |
738| ----------------------- | ------------------- | ---- | ---------------------------- |
739| newFileNames?              | Array<string>    | No | Names of the files to save. If this parameter is not specified, the user needs to enter the file names.|
740
741## DocumentSelectOptions
742
743Defines the options for selecting documents. Currently, this parameter cannot be configured.
744
745**System capability**: SystemCapability.FileManagement.UserFileService
746
747## DocumentSaveOptions
748
749Defines the options for saving documents.
750
751**System capability**: SystemCapability.FileManagement.UserFileService
752
753| Name                   | Type               | Mandatory|  Description                          |
754| ----------------------- | ------------------- | ---- | ---------------------------- |
755| newFileNames?            | Array<string>    | No  | Names of the documents to save. If this parameter is not specified, the user needs to enter the document names. |
756
757## AudioSelectOptions
758
759Defines the options for selecting audio files. Currently, this parameter cannot be configured.
760
761**System capability**: SystemCapability.FileManagement.UserFileService
762
763## AudioSaveOptions
764
765Defines the options for saving audio files.
766
767**System capability**: SystemCapability.FileManagement.UserFileService
768
769| Name                   | Type               | Mandatory|  Description                          |
770| ----------------------- | ------------------- | ---- | ---------------------------- |
771| newFileNames?              | Array<string>    | No | Name of the audio files to save. If this parameter is not specified, the user needs to enter the file names.|
772