• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.file.picker (Picker)
2
3> **NOTE**
4>
5> 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.
6
7The **picker** module encapsulates APIs of **PhotoViewPicker**, **DocumentViewPicker**, and **AudioViewPicker** to provide capabilities for selecting and saving images and videos, documents, and audio clips. The application can select the Picker as required. The APIs of this module must be called in a UIAbility. Otherwise, the **photoPicker** or **FilePicker** application cannot be started.
8
9## Modules to Import
10
11```ts
12import  { picker } from '@kit.CoreFileKit';
13```
14
15## DocumentViewPicker
16
17Provides APIs for selecting and saving documents in different formats. Before using the APIs of **DocumentViewPicker**, you need to create a **DocumentViewPicker** instance.
18
19**System capability**: SystemCapability.FileManagement.UserFileService
20
21### constructor<sup>12+</sup>
22
23constructor(context: Context)
24
25A constructor used to create a **DocumentViewPicker** instance. This constructor is recommended. For details about how to obtain the context, see [getContext](../apis-arkui/js-apis-getContext.md).
26
27**Atomic service API**: This API can be used in atomic services since API version 12.
28
29**System capability**: SystemCapability.FileManagement.UserFileService
30
31**Parameters**
32| Name | Type   | Mandatory| Description                                                        |
33| ------- | ------- | ---- | ------------------------------------------------------------ |
34| context | Context| Yes  | Application context (only **UIAbilityContext** is supported). For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
35
36**Example**
37
38```ts
39import { common } from '@kit.AbilityKit';
40import  { picker } from '@kit.CoreFileKit';
41@Entry
42@Component
43struct Index {
44  @State message: string = 'hello World';
45
46  build() {
47    Row() {
48      Column() {
49        Text(this.message)
50          .fontSize(50)
51          .fontWeight(FontWeight.Bold)
52          .onClick(()=>{
53            let context = getContext (this) as common.Context; // Ensure that getContext (this) returns UIAbilityContext.
54            let documentPicker = new picker.DocumentViewPicker(context);
55          })
56      }
57      .width('100%')
58    }
59    .height('100%')
60  }
61}
62```
63
64### constructor<sup>12+</sup>
65
66constructor()
67
68A constructor used to create a **DocumentViewPicker** instance. This constructor is not recommended due to the potential risk of operation failure.
69
70**Atomic service API**: This API can be used in atomic services since API version 12.
71
72**System capability**: SystemCapability.FileManagement.UserFileService
73
74**Example**
75
76```ts
77let documentPicker = new picker.DocumentViewPicker(); // Construction without parameter is not recommended. There is a possibility that the DocumentViewPicker instance fails to start.
78```
79
80### constructor<sup>13+</sup>
81
82constructor(context: Context, window: window.Window)
83
84A constructor used to create a **DocumentViewPicker** object in a window created by an application. In other scenarios, you are advised to use **constructor(context: Context)** to create a **DocumentViewPicker** object.
85
86**Parameters**
87| Name | Type   | Mandatory| Description                                                        |
88| ------- | ------- | ---- | ------------------------------------------------------------ |
89| context | Context| Yes  | Application context (only **UIAbilityContext** is supported). For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
90| window  | [window.Window](../apis-arkui/js-apis-window.md#window)  | Yes  | Window instance created by the application.|
91
92> **NOTE**
93>
94> Currently, only mobile phones are supported.
95
96**System capability**: SystemCapability.FileManagement.UserFileService
97
98**Example**
99
100```ts
101import { common } from '@kit.AbilityKit';
102import { picker } from '@kit.CoreFileKit';
103import { window } from '@kit.ArkUI';
104@Entry
105@Component
106struct Index {
107  @State message: string = 'hello World';
108
109  build() {
110    Row() {
111      Column() {
112        Text(this.message)
113          .fontSize(50)
114          .fontWeight(FontWeight.Bold)
115          .onClick(()=>{
116            let context = getContext (this) as common.Context; // Ensure that getContext (this) returns UIAbilityContext.
117            let windowClass: window.Window | undefined = undefined;
118            windowClass = window.findWindow ('test'); // Ensure that the window has been created. Here, 'test' is the value of the name parameter when the window is created.
119            let documentPicker = new picker.DocumentViewPicker(context, windowClass);
120          })
121      }
122      .width('100%')
123    }
124    .height('100%')
125  }
126}
127```
128
129### select
130
131select(option?: DocumentSelectOptions): Promise&lt;Array&lt;string&gt;&gt;
132
133Starts a **documentPicker** page for the user to select one or more documents. This API uses a promise to return the result. You can pass in **DocumentSelectOptions**.
134
135**NOTE**<br>For details about how to use the returned URIs, see [Using a Document URI](../../file-management/user-file-uri-intro.md#using-a-document-uri).
136
137**Atomic service API**: This API can be used in atomic services since API version 12.
138
139**System capability**: SystemCapability.FileManagement.UserFileService
140
141**Parameters**
142
143| Name | Type   | Mandatory| Description                      |
144| ------- | ------- | ---- | -------------------------- |
145| option | [DocumentSelectOptions](#documentselectoptions) | No  | Options for selecting documents. If this parameter is not specified, the **documentPicker** page is displayed by default.|
146
147**Return value**
148
149| Type                           | Description   |
150| ----------------------------- | :---- |
151| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the URIs of the documents selected.|
152
153**Example**
154
155```ts
156import { BusinessError } from '@kit.BasicServicesKit';
157import { common } from '@kit.AbilityKit';
158import  { picker } from '@kit.CoreFileKit';
159async function example07(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
160  try {
161    let documentSelectOptions = new picker.DocumentSelectOptions();
162    let documentPicker = new picker.DocumentViewPicker(context);
163    documentPicker.select(documentSelectOptions).then((documentSelectResult: Array<string>) => {
164      console.info('DocumentViewPicker.select successfully, documentSelectResult uri: ' + JSON.stringify(documentSelectResult));
165    }).catch((err: BusinessError) => {
166      console.error('DocumentViewPicker.select failed with err: ' + JSON.stringify(err));
167    });
168  } catch (error) {
169    let err: BusinessError = error as BusinessError;
170    console.error('DocumentViewPicker failed with err: ' + JSON.stringify(err));
171  }
172}
173```
174
175### select
176
177select(option: DocumentSelectOptions, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
178
179Starts a **documentPicker** page for the user to select one or more documents. This API uses an asynchronous callback to return the result. You can pass in **DocumentSelectOptions**.
180
181**NOTE**<br>For details about how to use the returned URIs, see [Using a Document URI](../../file-management/user-file-uri-intro.md#using-a-document-uri).
182
183**Atomic service API**: This API can be used in atomic services since API version 12.
184
185**System capability**: SystemCapability.FileManagement.UserFileService
186
187**Parameters**
188
189| Name | Type   | Mandatory| Description                      |
190| ------- | ------- | ---- | -------------------------- |
191| option | [DocumentSelectOptions](#documentselectoptions) | Yes  | Options for selecting documents.|
192| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;      | Yes  | Callback invoked to return the URIs of the documents selected.|
193
194**Example**
195
196```ts
197import { BusinessError } from '@kit.BasicServicesKit';
198import { common } from '@kit.AbilityKit';
199import  { picker } from '@kit.CoreFileKit';
200async function example08(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
201  try {
202    let documentSelectOptions = new picker.DocumentSelectOptions();
203    let documentPicker = new picker.DocumentViewPicker(context);
204    documentPicker.select(documentSelectOptions, (err: BusinessError, documentSelectResult: Array<string>) => {
205      if (err) {
206        console.error('DocumentViewPicker.select failed with err: ' + JSON.stringify(err));
207        return;
208      }
209      console.info('DocumentViewPicker.select successfully, documentSelectResult uri: ' + JSON.stringify(documentSelectResult));
210    });
211  } catch (error) {
212    let err: BusinessError = error as BusinessError;
213    console.error('DocumentViewPicker failed with err: ' + JSON.stringify(err));
214  }
215}
216```
217
218### select
219
220select(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
221
222Starts a **documentPicker** page for the user to select one or more documents. This API uses an asynchronous callback to return the result.
223
224**NOTE**<br>For details about how to use the returned URIs, see [Using a Document URI](../../file-management/user-file-uri-intro.md#using-a-document-uri).
225
226**Atomic service API**: This API can be used in atomic services since API version 12.
227
228**System capability**: SystemCapability.FileManagement.UserFileService
229
230**Parameters**
231
232| Name | Type   | Mandatory| Description                      |
233| ------- | ------- | ---- | -------------------------- |
234| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;      | Yes  | Callback invoked to return the URIs of the documents selected.|
235
236**Example**
237
238```ts
239import { BusinessError } from '@kit.BasicServicesKit';
240import { common } from '@kit.AbilityKit';
241import  { picker } from '@kit.CoreFileKit';
242async function example09(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
243  try {
244    let documentPicker = new picker.DocumentViewPicker(context);
245    documentPicker.select((err: BusinessError, documentSelectResult: Array<string>) => {
246      if (err) {
247        console.error('DocumentViewPicker.select failed with err: ' + JSON.stringify(err));
248        return;
249      }
250      console.info('DocumentViewPicker.select successfully, documentSelectResult uri: ' + JSON.stringify(documentSelectResult));
251    });
252  } catch (error) {
253    let err: BusinessError = error as BusinessError;
254    console.error('DocumentViewPicker failed with err: ' + JSON.stringify(err));
255  }
256}
257```
258
259### save
260
261save(option?: DocumentSaveOptions): Promise&lt;Array&lt;string&gt;&gt;
262
263Starts a **documentPicker** page for the user to save one or more documents. This API uses a promise to return the result. You can pass in **DocumentSaveOptions** to specify the file names to save.
264
265**NOTE**<br>For details about how to use the returned URIs, see [Using a Document URI](../../file-management/user-file-uri-intro.md#using-a-document-uri).
266
267**Atomic service API**: This API can be used in atomic services since API version 12.
268
269**System capability**: SystemCapability.FileManagement.UserFileService
270
271**Parameters**
272
273| Name | Type   | Mandatory| Description                      |
274| ------- | ------- | ---- | -------------------------- |
275| 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.|
276
277**Return value**
278
279| Type                           | Description   |
280| ----------------------------- | :---- |
281| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the URIs of the documents saved.|
282
283**Example**
284
285```ts
286import { BusinessError } from '@kit.BasicServicesKit';
287import { common } from '@kit.AbilityKit';
288import  { picker } from '@kit.CoreFileKit';
289async function example10(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
290  try {
291    let documentSaveOptions = new picker.DocumentSaveOptions();
292    documentSaveOptions.newFileNames = ['DocumentViewPicker01.txt'];
293    let documentPicker = new picker.DocumentViewPicker(context);
294    documentPicker.save(documentSaveOptions).then((documentSaveResult: Array<string>) => {
295      console.info('DocumentViewPicker.save successfully, documentSaveResult uri: ' + JSON.stringify(documentSaveResult));
296    }).catch((err: BusinessError) => {
297      console.error('DocumentViewPicker.save failed with err: ' + JSON.stringify(err));
298    });
299  } catch (error) {
300    let err: BusinessError = error as BusinessError;
301    console.error('DocumentViewPicker failed with err: ' + JSON.stringify(err));
302  }
303}
304```
305
306### save
307
308save(option: DocumentSaveOptions, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
309
310Starts a **documentPicker** page for the user to save one or more documents. This API uses an asynchronous callback to return the result. You can pass in **DocumentSaveOptions** to specify the file names to save.
311
312**NOTE**<br>For details about how to use the returned URIs, see [Using a Document URI](../../file-management/user-file-uri-intro.md#using-a-document-uri).
313
314**Atomic service API**: This API can be used in atomic services since API version 12.
315
316**System capability**: SystemCapability.FileManagement.UserFileService
317
318**Parameters**
319
320| Name | Type   | Mandatory| Description                      |
321| ------- | ------- | ---- | -------------------------- |
322| option | [DocumentSaveOptions](#documentsaveoptions) | Yes  | Options for saving the documents.|
323| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;      | Yes  | Callback invoked to return the URIs of the documents saved.|
324
325**Example**
326
327```ts
328import { BusinessError } from '@kit.BasicServicesKit';
329import { common } from '@kit.AbilityKit';
330import  { picker } from '@kit.CoreFileKit';
331async function example11(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
332  try {
333    let documentSaveOptions = new picker.DocumentSaveOptions();
334    documentSaveOptions.newFileNames = ['DocumentViewPicker02.txt'];
335    let documentPicker = new picker.DocumentViewPicker(context);
336    documentPicker.save(documentSaveOptions, (err: BusinessError, documentSaveResult: Array<string>) => {
337      if (err) {
338        console.error('DocumentViewPicker.save failed with err: ' + JSON.stringify(err));
339        return;
340      }
341      console.info('DocumentViewPicker.save successfully, documentSaveResult uri: ' + JSON.stringify(documentSaveResult));
342    });
343  } catch (error) {
344    let err: BusinessError = error as BusinessError;
345    console.error('DocumentViewPicker failed with err: ' + JSON.stringify(err));
346  }
347}
348```
349
350### save
351
352save(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
353
354Starts a **documentPicker** page for the user to save one or more documents. This API uses an asynchronous callback to return the result.
355
356**NOTE**<br>For details about how to use the returned URIs, see [Using a Document URI](../../file-management/user-file-uri-intro.md#using-a-document-uri).
357
358**Atomic service API**: This API can be used in atomic services since API version 12.
359
360**System capability**: SystemCapability.FileManagement.UserFileService
361
362**Parameters**
363
364| Name | Type   | Mandatory| Description                      |
365| ------- | ------- | ---- | -------------------------- |
366| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;      | Yes  | Callback invoked to return the URIs of the documents saved.|
367
368**Example**
369
370```ts
371import { BusinessError } from '@kit.BasicServicesKit';
372import { common } from '@kit.AbilityKit';
373import  { picker } from '@kit.CoreFileKit';
374async function example12(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
375  try {
376    let documentPicker = new picker.DocumentViewPicker(context);
377    documentPicker.save((err: BusinessError, documentSaveResult: Array<string>) => {
378      if (err) {
379        console.error('DocumentViewPicker.save failed with err: ' + JSON.stringify(err));
380        return;
381      }
382      console.info('DocumentViewPicker.save successfully, documentSaveResult uri: ' + JSON.stringify(documentSaveResult));
383    });
384  } catch (error) {
385    let err: BusinessError = error as BusinessError;
386    console.error('DocumentViewPicker failed with err: ' + JSON.stringify(err));
387  }
388}
389```
390
391### getSelectedIndex<sup>14+</sup>;
392
393getSelectedIndex(): number
394
395Obtains the subscript of the file name extension type of the file saved.
396
397This API is available only for 2-in-1 devices.
398
399This method takes effect only when used with [save()](#save).
400
401**getSelectedIndex()** can be used only after [DocumentSaveOptions.fileSuffixChoices](#documentsaveoptions) is configured.
402
403The subscript (number) returned by this method indicates the location of the filename extension specified in [DocumentSaveOptions.fileSuffixChoices](#documentsaveoptions). If no filename extension is specified, **getSelectedIndex()** returns **-1**.
404
405**Atomic service API**: This API can be used in atomic services since API version 14.
406
407**System capability**: SystemCapability.FileManagement.UserFileService.FolderSelection
408
409```ts
410import { BusinessError } from '@kit.BasicServicesKit';
411import { common } from '@kit.AbilityKit';
412import  { picker } from '@kit.CoreFileKit';
413async function exampleIndex(context: common.Context) { // Ensure that context is converted from UIAbilityContext.
414  try {
415    let documentSaveOptions = new picker.DocumentSaveOptions();
416    // Name of the file to save.
417    documentSaveOptions.newFileNames = ['DocumentViewPicker01'];
418    // File name extensions of the file to save.
419    documentSaveOptions.fileSuffixChoices = ['txt', 'mp4', 'pdf'];
420    let documentPicker = new picker.DocumentViewPicker(context);
421    documentPicker.save(documentSaveOptions).then((documentSaveResult: Array<string>) => {
422      if (documentSaveOptions.fileSuffixChoices != undefined && documentSaveResult != undefined) {
423        // Obtain the subscript of the filename extension of the file saved.
424        let index = documentPicker.getSelectedIndex();
425        // Obtain the filename extension of the file saved.
426        let selectedsuffix = documentSaveOptions.fileSuffixChoices[index];
427        console.info ('DocumentViewPicker.save selectedsuffix is ' + selectedsuffix);
428      }
429      console.info('DocumentViewPicker.save successfully, documentSaveResult uri: ' + JSON.stringify(documentSaveResult));
430    }).catch((err: BusinessError) => {
431      console.error('DocumentViewPicker.save failed with err: ' + JSON.stringify(err));
432    });
433  } catch (error) {
434    let err: BusinessError = error as BusinessError;
435    console.error('DocumentViewPicker failed with err: ' + JSON.stringify(err));
436  }
437}
438```
439## AudioViewPicker
440
441Provides APIs for selecting and saving audio clips. Before using the APIs of **AudioViewPicker**, you need to create an **AudioViewPicker** instance.
442
443**System capability**: SystemCapability.FileManagement.UserFileService
444
445### constructor<sup>12+</sup>
446
447constructor(context: Context)
448
449A constructor used to create an **AudioViewPicker** instance. This constructor is recommended. For details about how to obtain the context, see [getContext](../apis-arkui/js-apis-getContext.md).
450
451**Atomic service API**: This API can be used in atomic services since API version 12.
452
453**System capability**: SystemCapability.FileManagement.UserFileService
454
455**Parameters**
456| Name | Type   | Mandatory| Description                                                        |
457| ------- | ------- | ---- | ------------------------------------------------------------ |
458| context | Context| Yes  | Application context (only **UIAbilityContext** is supported). For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
459
460**Example**
461
462```ts
463import { common } from '@kit.AbilityKit';
464import  { picker } from '@kit.CoreFileKit';
465@Entry
466@Component
467struct Index {
468  @State message: string = 'hello World';
469
470  build() {
471    Row() {
472      Column() {
473        Text(this.message)
474          .fontSize(50)
475          .fontWeight(FontWeight.Bold)
476          .onClick(()=>{
477            let context = getContext (this) as common.Context; // Ensure that getContext (this) returns UIAbilityContext.
478            let audioPicker = new picker.AudioViewPicker(context);
479          })
480      }
481      .width('100%')
482    }
483    .height('100%')
484  }
485}
486```
487### constructor<sup>12+</sup>
488
489constructor()
490
491A constructor used to create an **AudioViewPicker** instance. This constructor is not recommended due to the potential risk of operation failure.
492
493**Atomic service API**: This API can be used in atomic services since API version 12.
494
495**System capability**: SystemCapability.FileManagement.UserFileService
496
497**Example**
498
499```ts
500let audioPicker = new picker.AudioViewPicker(); // Construction without parameter is not recommended. There is a possibility that the AudioViewPicker instance fails to start.
501```
502
503### select
504
505select(option?: AudioSelectOptions): Promise&lt;Array&lt;string&gt;&gt;
506
507Starts an **audioPicker** page for the user to select one or more audio clips. This API uses a promise to return the result. You can pass in **AudioSelectOptions**.
508
509**NOTE**<br>For details about how to use the URIs returned by this API, see [Using a Document URI](../../file-management/user-file-uri-intro.md#using-a-document-uri).
510
511**Atomic service API**: This API can be used in atomic services since API version 12.
512
513**System capability**: SystemCapability.FileManagement.UserFileService
514
515**Parameters**
516
517| Name | Type   | Mandatory| Description                      |
518| ------- | ------- | ---- | -------------------------- |
519| option | [AudioSelectOptions](#audioselectoptions) | No  | Options for selecting audio clips. If this parameter is not specified, the **audioPicker** page is displayed by default. |
520
521**Return value**
522
523| Type                           | Description   |
524| ----------------------------- | :---- |
525| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the URIs of the audio clips selected.|
526
527**Example**
528
529```ts
530import { BusinessError } from '@kit.BasicServicesKit';
531import { common } from '@kit.AbilityKit';
532import  { picker } from '@kit.CoreFileKit';
533async function example13(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
534  try {
535    let audioSelectOptions = new picker.AudioSelectOptions();
536    let audioPicker = new picker.AudioViewPicker(context);
537    audioPicker.select(audioSelectOptions).then((audioSelectResult: Array<string>) => {
538      console.info('AudioViewPicker.select successfully, audioSelectResult uri: ' + JSON.stringify(audioSelectResult));
539    }).catch((err: BusinessError) => {
540      console.error('AudioViewPicker.select failed with err: ' + JSON.stringify(err));
541    });
542  } catch (error) {
543    let err: BusinessError = error as BusinessError;
544    console.error('AudioViewPicker failed with err: ' + JSON.stringify(err));
545  }
546}
547```
548
549### select
550
551select(option: AudioSelectOptions, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
552
553Starts an **audioPicker** page for the user to select one or more audio clips. This API uses an asynchronous callback to return the result. You can pass in **AudioSelectOptions**.
554
555**NOTE**<br>For details about how to use the URIs returned by this API, see [Using a Document URI](../../file-management/user-file-uri-intro.md#using-a-document-uri).
556
557**System capability**: SystemCapability.FileManagement.UserFileService
558
559**Parameters**
560
561| Name | Type   | Mandatory| Description                      |
562| ------- | ------- | ---- | -------------------------- |
563| option | [AudioSelectOptions](#audioselectoptions) | Yes  | Options for selecting audio clips.|
564| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;      | Yes  | Callback invoked to return the URIs of the audio clips selected.|
565
566**Example**
567
568```ts
569import { BusinessError } from '@kit.BasicServicesKit';
570import { common } from '@kit.AbilityKit';
571import  { picker } from '@kit.CoreFileKit';
572async function example14(context: common.Context) { // Ensure that context is converted from UIAbilityContext.
573  try {
574    let audioSelectOptions = new picker.AudioSelectOptions();
575    let audioPicker = new picker.AudioViewPicker(context);
576    audioPicker.select(audioSelectOptions, (err: BusinessError, audioSelectResult: Array<string>) => {
577      if (err) {
578        console.error('AudioViewPicker.select failed with err: ' + JSON.stringify(err));
579        return;
580      }
581      console.info('AudioViewPicker.select successfully, audioSelectResult uri: ' + JSON.stringify(audioSelectResult));
582    });
583  } catch (error) {
584    let err: BusinessError = error as BusinessError;
585    console.error('AudioViewPicker failed with err: ' + JSON.stringify(err));
586  }
587}
588```
589
590### select
591
592select(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
593
594Starts an **audioPicker** page for the user to select one or more audio clips. This API uses an asynchronous callback to return the result.
595
596**NOTE**<br>For details about how to use the URIs returned by this API, see [Using a Document URI](../../file-management/user-file-uri-intro.md#using-a-document-uri).
597
598**System capability**: SystemCapability.FileManagement.UserFileService
599
600**Parameters**
601
602| Name | Type   | Mandatory| Description                      |
603| ------- | ------- | ---- | -------------------------- |
604| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;      | Yes  | Callback invoked to return the URIs of the audio clips selected.|
605
606**Example**
607
608```ts
609import { BusinessError } from '@kit.BasicServicesKit';
610import { common } from '@kit.AbilityKit';
611import  { picker } from '@kit.CoreFileKit';
612async function example15(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
613  try {
614    let audioPicker = new picker.AudioViewPicker(context);
615    audioPicker.select((err: BusinessError, audioSelectResult: Array<string>) => {
616      if (err) {
617        console.error('AudioViewPicker.select failed with err: ' + JSON.stringify(err));
618        return;
619      }
620      console.info('AudioViewPicker.select successfully, audioSelectResult uri: ' + JSON.stringify(audioSelectResult));
621    });
622  } catch (error) {
623    let err: BusinessError = error as BusinessError;
624    console.error('AudioViewPicker failed with err: ' + JSON.stringify(err));
625  }
626}
627```
628
629### save
630
631save(option?: AudioSaveOptions): Promise&lt;Array&lt;string&gt;&gt;
632
633Starts an **audioPicker** page (currently, a **documentPicker** page is displayed) for the user to save one or more audio clips. This API uses a promise to return the result. You can pass in **AudioSaveOptions** to specify the file names of the audio clips to save.
634
635**NOTE**<br>For details about how to use the returned URIs, see [Using a Document URI](../../file-management/user-file-uri-intro.md#using-a-document-uri).
636
637**Atomic service API**: This API can be used in atomic services since API version 12.
638
639**System capability**: SystemCapability.FileManagement.UserFileService
640
641**Parameters**
642
643| Name | Type   | Mandatory| Description                      |
644| ------- | ------- | ---- | -------------------------- |
645| option | [AudioSaveOptions](#audiosaveoptions) | No  | Options for saving audio clips. If this parameter is not specified, an **audioPicker** page will be displayed for the user to enter the names of the files to save.|
646
647**Return value**
648
649| Type                           | Description   |
650| ----------------------------- | ---- |
651| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the URIs of the audio clips saved.|
652
653**Example**
654
655```ts
656import { BusinessError } from '@kit.BasicServicesKit';
657import { common } from '@kit.AbilityKit';
658import  { picker } from '@kit.CoreFileKit';
659async function example16(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
660  try {
661    let audioSaveOptions = new picker.AudioSaveOptions();
662    audioSaveOptions.newFileNames = ['AudioViewPicker01.mp3'];
663    let audioPicker = new picker.AudioViewPicker(context);
664    audioPicker.save(audioSaveOptions).then((audioSaveResult: Array<string>) => {
665      console.info('AudioViewPicker.save successfully, audioSaveResult uri: ' + JSON.stringify(audioSaveResult))
666    }).catch((err: BusinessError) => {
667      console.error('AudioViewPicker.save failed with err: ' + JSON.stringify(err));
668    });
669  } catch (error) {
670    let err: BusinessError = error as BusinessError;
671    console.error('AudioViewPicker failed with err: ' + JSON.stringify(err));
672  }
673}
674```
675
676### save
677
678save(option: AudioSaveOptions, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
679
680Starts an **audioPicker** page (currently, a **documentPicker** page is displayed) for the user to save one or more audio clips. This API uses an asynchronous callback to return the result. You can pass in **AudioSaveOptions** to specify the file names of the audio clips to save.
681
682**NOTE**<br>For details about how to use the returned URIs, see [Using a Document URI](../../file-management/user-file-uri-intro.md#using-a-document-uri).
683
684**System capability**: SystemCapability.FileManagement.UserFileService
685
686**Parameters**
687
688| Name | Type   | Mandatory| Description                      |
689| ------- | ------- | ---- | -------------------------- |
690| option | [AudioSaveOptions](#audiosaveoptions) | Yes  | Options for saving audio clips.|
691| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;      | Yes  | Callback invoked to return the URIs of the audio clips saved.|
692
693**Example**
694
695```ts
696import { BusinessError } from '@kit.BasicServicesKit';
697import { common } from '@kit.AbilityKit';
698import  { picker } from '@kit.CoreFileKit';
699async function example17(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
700  try {
701    let audioSaveOptions = new picker.AudioSaveOptions();
702    audioSaveOptions.newFileNames = ['AudioViewPicker02.mp3'];
703    let audioPicker = new picker.AudioViewPicker(context);
704    audioPicker.save(audioSaveOptions, (err: BusinessError, audioSaveResult: Array<string>) => {
705      if (err) {
706        console.error('AudioViewPicker.save failed with err: ' + JSON.stringify(err));
707        return;
708      }
709      console.info('AudioViewPicker.save successfully, audioSaveResult uri: ' + JSON.stringify(audioSaveResult));
710    });
711  } catch (error) {
712    let err: BusinessError = error as BusinessError;
713    console.error('AudioViewPicker failed with err: ' + JSON.stringify(err));
714  }
715}
716```
717
718### save
719
720save(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
721
722Starts an **audioPicker** page (currently, a **documentPicker** page is displayed) for the user to save one or more audio clips. This API uses an asynchronous callback to return the result.
723
724**NOTE**<br>For details about how to use the returned URIs, see [Using a Document URI](../../file-management/user-file-uri-intro.md#using-a-document-uri).
725
726**System capability**: SystemCapability.FileManagement.UserFileService
727
728**Parameters**
729
730| Name | Type   | Mandatory| Description                      |
731| ------- | ------- | ---- | -------------------------- |
732| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;      | Yes  | Callback invoked to return the URIs of the audio clips saved.|
733
734**Example**
735
736```ts
737import { BusinessError } from '@kit.BasicServicesKit';
738import { common } from '@kit.AbilityKit';
739import  { picker } from '@kit.CoreFileKit';
740async function example18(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
741  try {
742    let audioPicker = new picker.AudioViewPicker(context);
743    audioPicker.save((err: BusinessError, audioSaveResult: Array<string>) => {
744      if (err) {
745        console.error('AudioViewPicker.save failed with err: ' + JSON.stringify(err));
746        return;
747      }
748      console.info('AudioViewPicker.save successfully, audioSaveResult uri: ' + JSON.stringify(audioSaveResult));
749    });
750  } catch (error) {
751    let err: BusinessError = error as BusinessError;
752    console.error('AudioViewPicker failed with err: ' + JSON.stringify(err));
753  }
754}
755```
756
757## DocumentSelectMode<sup>11+</sup>
758
759Enumerates the types of files that can be selected by Picker.
760
761Only 2-in-1 devices are supported.
762
763**Atomic service API**: This API can be used in atomic services since API version 12.
764
765**System capability**: SystemCapability.FileManagement.UserFileService.FolderSelection
766
767| Name |  Value|  Description|
768| ----- |  ---- | ---- |
769| FILE  | 0  | File type. |
770| FOLDER | 1  | Folder. |
771| MIXED | 2  | Mixed type of files and folders. |
772
773## DocumentSelectOptions
774
775Defines the options for selecting documents.
776
777**Atomic service API**: This API can be used in atomic services since API version 12.
778
779**System capability**: SystemCapability.FileManagement.UserFileService
780
781| Name                   | Type                                         | Mandatory| Description                                      |
782| :---------------------- |---------------------------------------------| ---- |------------------------------------------|
783| maxSelectNumber<sup>10+</sup>       | number                                      | No  | Maximum number of documents that can be selected.<br>Value range: 1 to 500.<br>Only the devices that have the required system capability can select folders, and only one folder can be selected at a time. <br>Default value: **1**.<br>**System capability**: SystemCapability.FileManagement.UserFileService |
784| defaultFilePathUri<sup>10+</sup>    | string                                      | No  | Path of the documents or folder to select. The default value is empty (the recently opened page is displayed).          |
785| fileSuffixFilters<sup>10+</sup>     | Array&lt;string&gt;                         | No  | File name extensions of the documents to select. The value is a string array. Each element specifies an option, which includes at most two parts with a vertical bar (|) in between.|The first part is the description (optional), and the second part is the file name extension information. If there is no "|",|the option does not have the description. Multiple file name extensions separated by a comma (,) are allowed in an option. The number of elements in a string array cannot exceed 100. This parameter is available only to the devices that have the required system capability. By default, no filtering is performed, that is, all files are displayed.<br>**System capability**: SystemCapability.FileManagement.UserFileService  |
786| selectMode<sup>11+</sup>         | [DocumentSelectMode](#documentselectmode11) | No  | Only 2in1 devices are supported. The default value is **File**.<br>**System capability**: SystemCapability.FileManagement.UserFileService.FolderSelection |
787| authMode<sup>12+</sup>    | boolean                              | No  | Whether to start Picker.<br>Default value: **false**. If **authMode** is **true**, **defaultFilePathUri** is mandatory, which specifies the URI of the file allowed to access. Only 2in1 devices are supported.<br>**System capability**: SystemCapability.FileManagement.UserFileService.FolderSelection |
788|multiAuthMode<sup>15+</sup>  | boolean                             |No   | The batch authorization mode is supported. The default value **false** indicates the non-batch authorization mode. When **multAuthMode** is set to **true**, the batch authorization mode is used. And only the **multiUriArray** parameter takes effect. Only mobile phones are supported.<br>**Atomic service API**: This API can be used in atomic services since API version 15.|
789|multiUriArray<sup>15+</sup>  | Array&lt;string&gt;                             |No   | URI array for batch authorization. (Only files are supported. Folders are not supported.) This parameter is used together with **multAuthMode**. This parameter does not take effect when **multAuthMode** is set to **false**. The default value is empty. (The file displayed after the batch authorization page is opened is empty.) Only mobile phones are supported.<br>**Atomic service API**: This API can be used in atomic services since API version 15.|
790|mergeMode<sup>15+</sup>  | [MergeTypeMode](#mergetypemode15)                             |No   | Enables the aggregation view mode. The aggregation view of the file management application can be started. The default value is **DEFAULT**, indicating that this parameter does not take effect and the view is not an aggregation view. If this parameter is set to a value other than **DEFAULT**, other parameters do not take effect. Only mobile phones are supported.<br>**Atomic service API**: This API can be used in atomic services since API version 15.|
791## DocumentPickerMode<sup>12+</sup>
792
793Enumerates the modes for saving documents.
794
795**Atomic service API**: This API can be used in atomic services since API version 12.
796
797**System capability**: SystemCapability.FileManagement.UserFileService
798
799| Name |  Value|  Description|
800| ----- |  ---- | ---- |
801| DEFAULT  | 0  | Standard mode.|
802| DOWNLOAD | 1  | Download mode.|
803
804## MergeTypeMode<sup>15+</sup>
805
806Enumerates file aggregation types. Only mobile phones are supported.
807
808**Atomic service API**: This API can be used in atomic services since API version 15.
809
810**System capability**: SystemCapability.FileManagement.UserFileService
811
812| Name |  Value|  Description|
813| ----- | ---- | ---- |
814| DEFAULT  | 0  | Default mode, indicating that this parameter does not take effect.|
815| AUDIO | 1  | Audio mode.|
816| VIDEO  | 2  | Video mode.|
817| DOCUMENT | 3  | Document mode.|
818| PICTURE  | 4  | Image mode.|
819
820## DocumentSaveOptions
821
822Defines the options for saving documents.
823
824**Atomic service API**: This API can be used in atomic services since API version 12.
825
826**System capability**: SystemCapability.FileManagement.UserFileService
827
828| Name                   | Type               | Mandatory|  Description                          |
829| ----------------------- | ------------------- | ---- | ---------------------------- |
830| newFileNames            | Array&lt;string&gt;    | No  | File names of the documents to save. If this parameter is not specified, the user needs to enter the document names. |
831| defaultFilePathUri<sup>10+</sup>    | string  | No  | Path of the documents or folder to save. |
832| fileSuffixChoices<sup>10+</sup>     | Array&lt;string&gt; | No  | File name extensions of the documents to save. The value is a string array. Each element specifies an option, which includes at most two parts with a vertical bar (|) in between.|The first part is the description, and the second part is the file name extension information. If there is no "|",|the option does not have the description. By default, all documents are saved.|
833| pickerMode<sup>12+</sup>     | [DocumentPickerMode](#documentpickermode12) | No  | Mode for starting Picker.<br>Default value: **DEFAULT**. If **pickerMode** is **DOWNLOAD**, the settings of **newFileNames**, **defaultFilePathUri**, and **fileSuffixChoices** do not take effect.|
834
835## AudioSelectOptions
836
837Defines the options for selecting audio clips.
838
839**Atomic service API**: This API can be used in atomic services since API version 12.
840
841**System capability**: SystemCapability.FileManagement.UserFileService
842| Name                   | Type                                         | Mandatory| Description                                      |
843| :---------------------- |---------------------------------------------| ---- |------------------------------------------|
844| maxSelectNumber<sup>12+</sup>       | number                                      | No  | Maximum number of audio clips that can be selected.<br>Default value: **1**<br>Value range: 1 to 500|
845
846## AudioSaveOptions
847
848Defines the options for saving audio clips.
849
850**Atomic service API**: This API can be used in atomic services since API version 12.
851
852**System capability**: SystemCapability.FileManagement.UserFileService
853
854| Name                   | Type               | Mandatory|  Description                          |
855| ----------------------- | ------------------- | ---- | ---------------------------- |
856| newFileNames              | Array&lt;string&gt;    | No | File names of the audio clips to save. If this parameter is not specified, the user needs to enter the document names.|
857
858## PhotoViewPicker<sup>(deprecated)</sup>
859
860Provides APIs for selecting and saving images/videos. You are advised to use [PhotoViewPicker of PhotoAccessHelper](../apis-media-library-kit/js-apis-photoAccessHelper.md#photoviewpicker) to select files. Before using the APIs of **PhotoViewPicker**, you need to create a **PhotoViewPicker** instance.
861
862> **NOTE**
863>
864> This API is supported since API version 9 and deprecated since API version 12. Use [photoAccessHelper.PhotoViewPicker](../apis-media-library-kit/js-apis-photoAccessHelper.md#photoviewpicker) instead.
865
866**System capability**: SystemCapability.FileManagement.UserFileService
867
868### constructor<sup>12+</sup>
869
870constructor(context: Context)
871
872**System capability**: SystemCapability.FileManagement.UserFileService
873
874A constructor used to create a **PhotoViewPicker** instance. This constructor is recommended. For details about how to obtain the context, see [getContext](../apis-arkui/js-apis-getContext.md).
875
876**Example**
877
878```ts
879import { common } from '@kit.AbilityKit';
880import  { picker } from '@kit.CoreFileKit';
881@Entry
882@Component
883struct Index {
884  @State message: string = 'hello World';
885
886  build() {
887    Row() {
888      Column() {
889        Text(this.message)
890          .fontSize(50)
891          .fontWeight(FontWeight.Bold)
892          .onClick(()=>{
893            let context = getContext (this) as common.Context; // Ensure that getContext (this) returns UIAbilityContext.
894            let photoPicker = new picker.PhotoViewPicker(context);
895          })
896      }
897      .width('100%')
898    }
899    .height('100%')
900  }
901}
902```
903
904### constructor<sup>12+</sup>
905
906constructor()
907
908**Atomic service API**: This API can be used in atomic services since API version 12.
909
910**System capability**: SystemCapability.FileManagement.UserFileService
911
912A constructor used to create a **PhotoViewPicker** instance. This constructor is not recommended due to the potential risk of operation failure.
913
914**Example**
915
916```ts
917let photoPicker = new picker.PhotoViewPicker(); // Construction without parameter is not recommended. There is a possibility that the PhotoViewPicker instance fails to start.
918```
919
920### select
921
922select(option?: PhotoSelectOptions): Promise&lt;PhotoSelectResult&gt;
923
924Starts a **photoPicker** page for the user to select one or more images/videos. This API uses a promise to return the result. You can pass in **PhotoSelectOptions** to specify the type and maximum number of the files to select.
925
926> **NOTE**
927>
928> This API is supported since API version 9 and deprecated since API version 12. Use [photoAccessHelper.PhotoViewPicker#select](../apis-media-library-kit/js-apis-photoAccessHelper.md#select) instead.
929
930**NOTE**<br>The **photoUris** in the **PhotoSelectResult** object returned by this API can be used only by [photoAccessHelper.getAssets](../apis-media-library-kit/js-apis-photoAccessHelper.md#getassets). For details, see [Using a Media File URI](../../file-management/user-file-uri-intro.md#using-a-media-file-uri).
931
932**Atomic service API**: This API can be used in atomic services since API version 11.
933
934**System capability**: SystemCapability.FileManagement.UserFileService
935
936**Parameters**
937
938| Name | Type   | Mandatory| Description                      |
939| ------- | ------- | ---- | -------------------------- |
940| option | [PhotoSelectOptions](#photoselectoptionsdeprecated) | No  | Options for selecting images/videos. If this parameter is not specified, images and videos are selected by default. A maximum of 50 files can be selected.|
941
942**Return value**
943
944| Type                           | Description   |
945| ----------------------------- | :---- |
946| Promise&lt;[PhotoSelectResult](#photoselectresultdeprecated)&gt; | Promise used to return a **PhotoSelectResult** object.|
947
948**Example**
949
950```ts
951import { BusinessError } from '@kit.BasicServicesKit';
952import { common } from '@kit.AbilityKit';
953import  { picker } from '@kit.CoreFileKit';
954async function example01(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
955  try {
956    let photoSelectOptions = new picker.PhotoSelectOptions();
957    photoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE;
958    photoSelectOptions.maxSelectNumber = 5;
959    let photoPicker = new picker.PhotoViewPicker(context);
960    photoPicker.select(photoSelectOptions).then((photoSelectResult: picker.PhotoSelectResult) => {
961      console.info('PhotoViewPicker.select successfully, photoSelectResult uri: ' + JSON.stringify(photoSelectResult));
962    }).catch((err: BusinessError) => {
963      console.error('PhotoViewPicker.select failed with err: ' + JSON.stringify(err));
964    });
965  } catch (error) {
966    let err: BusinessError = error as BusinessError;
967    console.error('PhotoViewPicker failed with err: ' + JSON.stringify(err));
968  }
969}
970```
971
972### select
973
974select(option: PhotoSelectOptions, callback: AsyncCallback&lt;PhotoSelectResult&gt;): void
975
976Starts a **photoPicker** page for the user to select one or more images/videos. This API uses an asynchronous callback to return the result. You can pass in **PhotoSelectOptions** to specify the type and maximum number of the files to select.
977
978> **NOTE**
979>
980> This API is supported since API version 9 and deprecated since API version 12. Use [photoAccessHelper.PhotoViewPicker#select](../apis-media-library-kit/js-apis-photoAccessHelper.md#select-1) instead.
981
982**NOTE**<br>The **photoUris** in the **PhotoSelectResult** object returned by this API can be used only by [photoAccessHelper.getAssets](../apis-media-library-kit/js-apis-photoAccessHelper.md#getassets). For details, see [Using a Media File URI](../../file-management/user-file-uri-intro.md#using-a-media-file-uri).
983
984**Atomic service API**: This API can be used in atomic services since API version 11.
985
986**System capability**: SystemCapability.FileManagement.UserFileService
987
988**Parameters**
989
990| Name | Type   | Mandatory| Description                      |
991| ------- | ------- | ---- | -------------------------- |
992| option | [PhotoSelectOptions](#photoselectoptionsdeprecated) | Yes  | Options for selecting images/videos.|
993| callback | AsyncCallback&lt;[PhotoSelectResult](#photoselectresultdeprecated)&gt;      | Yes  | Callback used to return information about the images or videos selected.|
994
995**Example**
996
997```ts
998import { BusinessError } from '@kit.BasicServicesKit';
999import { common } from '@kit.AbilityKit';
1000import  { picker } from '@kit.CoreFileKit';
1001async function example02(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
1002  try {
1003    let photoSelectOptions = new picker.PhotoSelectOptions();
1004    photoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE;
1005    photoSelectOptions.maxSelectNumber = 5;
1006    let photoPicker = new picker.PhotoViewPicker(context);
1007    photoPicker.select(photoSelectOptions, (err: BusinessError, photoSelectResult: picker.PhotoSelectResult) => {
1008      if (err) {
1009        console.error('PhotoViewPicker.select failed with err: ' + JSON.stringify(err));
1010        return;
1011      }
1012      console.info('PhotoViewPicker.select successfully, photoSelectResult uri: ' + JSON.stringify(photoSelectResult));
1013    });
1014  } catch (error) {
1015    let err: BusinessError = error as BusinessError;
1016    console.error('PhotoViewPicker failed with err: ' + JSON.stringify(err));
1017  }
1018}
1019```
1020
1021### select
1022
1023select(callback: AsyncCallback&lt;PhotoSelectResult&gt;): void
1024
1025Starts a **photoPicker** page for the user to select one or more images/videos. This API uses an asynchronous callback to return the result.
1026
1027> **NOTE**
1028>
1029> This API is supported since API version 9 and deprecated since API version 12. Use [photoAccessHelper.PhotoViewPicker#select](../apis-media-library-kit/js-apis-photoAccessHelper.md#select-2) instead.
1030
1031**NOTE**<br>The **photoUris** in the **PhotoSelectResult** object returned by this API can be used only by [photoAccessHelper.getAssets](../apis-media-library-kit/js-apis-photoAccessHelper.md#getassets). For details, see [Using a Media File URI](../../file-management/user-file-uri-intro.md#using-a-media-file-uri).
1032
1033**Atomic service API**: This API can be used in atomic services since API version 11.
1034
1035**System capability**: SystemCapability.FileManagement.UserFileService
1036
1037**Parameters**
1038
1039| Name | Type   | Mandatory| Description                      |
1040| ------- | ------- | ---- | -------------------------- |
1041| callback | AsyncCallback&lt;[PhotoSelectResult](#photoselectresultdeprecated)&gt;      | Yes  | Callback used to return information about the images or videos selected.|
1042
1043**Example**
1044
1045```ts
1046import { BusinessError } from '@kit.BasicServicesKit';
1047import { common } from '@kit.AbilityKit';
1048import  { picker } from '@kit.CoreFileKit';
1049async function example03(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
1050  try {
1051    let photoPicker = new picker.PhotoViewPicker(context);
1052    photoPicker.select((err: BusinessError, photoSelectResult: picker.PhotoSelectResult) => {
1053      if (err) {
1054        console.error('PhotoViewPicker.select failed with err: ' + JSON.stringify(err));
1055        return;
1056      }
1057      console.info('PhotoViewPicker.select successfully, photoSelectResult uri: ' + JSON.stringify(photoSelectResult));
1058    });
1059  } catch (error) {
1060    let err: BusinessError = error as BusinessError;
1061    console.error('PhotoViewPicker failed with err: ' + JSON.stringify(err));
1062  }
1063}
1064```
1065
1066### save
1067
1068save(option?: PhotoSaveOptions): Promise&lt;Array&lt;string&gt;&gt;
1069
1070Starts a **photoPicker** page for the user to save one or more images/videos. This API uses a promise to return the result. You can pass in **PhotoSaveOptions** to specify the file names of the images/videos to save.
1071
1072> **NOTE**
1073>
1074> This API is supported since API version 9 and deprecated since API version 12. Use [SaveButton](../apis-arkui/arkui-ts/ts-security-components-savebutton.md#savebutton) instead.
1075
1076**NOTE**<br>This API saves files in **Files**, not in **Gallery**. For details about how to use the returned URIs, see [Using a Document URI](../../file-management/user-file-uri-intro.md#using-a-document-uri).
1077
1078**System capability**: SystemCapability.FileManagement.UserFileService
1079
1080**Parameters**
1081
1082| Name | Type   | Mandatory| Description                      |
1083| ------- | ------- | ---- | -------------------------- |
1084| option | [PhotoSaveOptions](#photosaveoptionsdeprecated) | No  | Options for saving images/videos. If this parameter is not specified, a **photoPicker** page will be displayed for the user to enter the names of the files to save.|
1085
1086**Return value**
1087
1088| Type                           | Description   |
1089| ----------------------------- | :---- |
1090| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the URIs of the files saved.|
1091
1092**Example**
1093
1094```ts
1095import { BusinessError } from '@kit.BasicServicesKit';
1096import { common } from '@kit.AbilityKit';
1097import  { picker } from '@kit.CoreFileKit';
1098async function example04(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
1099  try {
1100    let photoSaveOptions = new picker.PhotoSaveOptions();
1101    photoSaveOptions.newFileNames = ['PhotoViewPicker01.jpg', 'PhotoViewPicker01.mp4'];
1102    let photoPicker = new picker.PhotoViewPicker(context);
1103    photoPicker.save(photoSaveOptions).then((photoSaveResult: Array<string>) => {
1104      console.info('PhotoViewPicker.save successfully, photoSaveResult uri: ' + JSON.stringify(photoSaveResult));
1105    }).catch((err: BusinessError) => {
1106      console.error('PhotoViewPicker.save failed with err: ' + JSON.stringify(err));
1107    });
1108  } catch (error) {
1109    let err: BusinessError = error as BusinessError;
1110      console.error('PhotoViewPicker failed with err: ' + JSON.stringify(err));
1111  }
1112}
1113```
1114
1115### save
1116
1117save(option: PhotoSaveOptions, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
1118
1119Starts a **photoPicker** page for the user to save one or more images/videos. This API uses an asynchronous callback to return the result. You can pass in **PhotoSaveOptions** to specify the file names of the images/videos to save.
1120
1121> **NOTE**
1122>
1123> This API is supported since API version 9 and deprecated since API version 12. Use [SaveButton](../apis-arkui/arkui-ts/ts-security-components-savebutton.md#savebutton) instead.
1124
1125**NOTE**<br>This API saves files in **Files**, not in **Gallery**. For details about how to use the returned URIs, see [Using a Document URI](../../file-management/user-file-uri-intro.md#using-a-document-uri).
1126
1127**System capability**: SystemCapability.FileManagement.UserFileService
1128
1129**Parameters**
1130
1131| Name | Type   | Mandatory| Description                      |
1132| ------- | ------- | ---- | -------------------------- |
1133| option | [PhotoSaveOptions](#photosaveoptionsdeprecated) | Yes  | Options for saving images/videos.|
1134| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;      | Yes  | Callback invoked to return the URIs of the files saved.|
1135
1136**Example**
1137
1138```ts
1139import { BusinessError } from '@kit.BasicServicesKit';
1140import { common } from '@kit.AbilityKit';
1141import  { picker } from '@kit.CoreFileKit';
1142async function example05(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
1143  try {
1144    let photoSaveOptions = new picker.PhotoSaveOptions();
1145    photoSaveOptions.newFileNames = ['PhotoViewPicker02.jpg','PhotoViewPicker02.mp4'];
1146    let photoPicker = new picker.PhotoViewPicker(context);
1147    photoPicker.save(photoSaveOptions, (err: BusinessError, photoSaveResult: Array<string>) => {
1148      if (err) {
1149        console.error('PhotoViewPicker.save failed with err: ' + JSON.stringify(err));
1150        return;
1151      }
1152      console.info('PhotoViewPicker.save successfully, photoSaveResult uri: ' + JSON.stringify(photoSaveResult));
1153    });
1154  } catch (error) {
1155    let err: BusinessError = error as BusinessError;
1156    console.error('PhotoViewPicker failed with err: ' + JSON.stringify(err));
1157  }
1158}
1159```
1160
1161### save
1162
1163save(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
1164
1165Starts a **photoPicker** page for the user to save one or more images/videos. This API uses an asynchronous callback to return the result.
1166
1167> **NOTE**
1168>
1169> This API is supported since API version 9 and deprecated since API version 12. Use [SaveButton](../apis-arkui/arkui-ts/ts-security-components-savebutton.md#savebutton) instead.
1170
1171**NOTE**<br>This API saves files in **Files**, not in **Gallery**. For details about how to use the returned URIs, see [Using a Document URI](../../file-management/user-file-uri-intro.md#using-a-document-uri).
1172
1173**System capability**: SystemCapability.FileManagement.UserFileService
1174
1175**Parameters**
1176
1177| Name | Type   | Mandatory| Description                      |
1178| ------- | ------- | ---- | -------------------------- |
1179| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;      | Yes  | Callback invoked to return the URIs of the files saved.|
1180
1181**Example**
1182
1183```ts
1184import { BusinessError } from '@kit.BasicServicesKit';
1185import { common } from '@kit.AbilityKit';
1186import  { picker } from '@kit.CoreFileKit';
1187async function example06(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
1188  try {
1189    let photoPicker = new picker.PhotoViewPicker(context);
1190    photoPicker.save((err: BusinessError, photoSaveResult: Array<string>) => {
1191      if (err) {
1192        console.error('PhotoViewPicker.save failed with err: ' + JSON.stringify(err));
1193        return;
1194      }
1195      console.info('PhotoViewPicker.save successfully, photoSaveResult uri: ' + JSON.stringify(photoSaveResult));
1196    });
1197  } catch (error) {
1198    let err: BusinessError = error as BusinessError;
1199    console.error('PhotoViewPicker failed with err: ' + JSON.stringify(err));
1200  }
1201}
1202```
1203
1204## PhotoViewMIMETypes<sup>(deprecated)</sup>
1205
1206Enumerates the media file types that can be selected.
1207
1208> **NOTE**
1209>
1210> This API is supported since API version 9 and deprecated since API version 12. Use [photoAccessHelper.PhotoViewMIMETypes](../apis-media-library-kit/js-apis-photoAccessHelper.md#photoviewmimetypes) instead.
1211
1212**Atomic service API**: This API can be used in atomic services since API version 11.
1213
1214**System capability**: SystemCapability.FileManagement.UserFileService
1215
1216| Name |  Value|  Description|
1217| ----- |  ---- | ---- |
1218| IMAGE_TYPE  |  'image/*' | Image. |
1219| VIDEO_TYPE |  'video/*' | Video. |
1220| IMAGE_VIDEO_TYPE |  '\*/*' | Image and video. |
1221
1222## PhotoSelectOptions<sup>(deprecated)</sup>
1223
1224Defines the options for selecting images/videos.
1225
1226> **NOTE**
1227>
1228> This API is supported since API version 9 and deprecated since API version 12. Use [photoAccessHelper.PhotoSelectOptions](../apis-media-library-kit/js-apis-photoAccessHelper.md#photoselectoptions) instead.
1229
1230**Atomic service API**: This API can be used in atomic services since API version 11.
1231
1232**System capability**: SystemCapability.FileManagement.UserFileService
1233
1234| Name                   | Type               | Mandatory| Description                         |
1235| ----------------------- | ------------------- | ---- | -------------------------------- |
1236| MIMEType              | [PhotoViewMIMETypes](#photoviewmimetypesdeprecated)   | No  | Media file types to select. **IMAGE_VIDEO_TYPE** is used by default. |
1237| maxSelectNumber       | number | No  | Maximum number of media files that can be selected. The default value is **50**, and the maximum value is **500**.     |
1238
1239## PhotoSelectResult<sup>(deprecated)</sup>
1240
1241Defines information about the images/videos selected.
1242
1243> **NOTE**
1244>
1245> This API is supported since API version 9 and deprecated since API version 12. Use [photoAccessHelper.PhotoSelectResult](../apis-media-library-kit/js-apis-photoAccessHelper.md#photoselectresult) instead.
1246
1247**Atomic service API**: This API can be used in atomic services since API version 11.
1248
1249**System capability**: SystemCapability.FileManagement.UserFileService
1250
1251| Name                   | Type               | Mandatory| Description                          |
1252| ----------------------- | ------------------- | ----| ------------------------------ |
1253| photoUris        | Array&lt;string&gt;    | Yes  | URIs of the media files selected. This URI array can be used only by [photoAccessHelper.getAssets](../apis-media-library-kit/js-apis-photoAccessHelper.md#getassets). For details, see [Using a Media File URI](../../file-management/user-file-uri-intro.md#using-a-media-file-uri). |
1254| isOriginalPhoto        | boolean    | Yes  | Whether the selected image is the original one. The value **true** means the selected image is the original one, and **false** means the opposite. |
1255
1256## PhotoSaveOptions<sup>(deprecated)</sup>
1257
1258Defines the options for saving images or videos.
1259
1260> **NOTE**
1261>
1262> This API is supported since API version 9 and deprecated since API version 12. There is no substitute API.
1263
1264**System capability**: SystemCapability.FileManagement.UserFileService
1265
1266| Name                   | Type               | Mandatory|  Description                          |
1267| ----------------------- | ------------------- | ---- | ---------------------------- |
1268| newFileNames              | Array&lt;string&gt;    | No | Files names of the images or videos to save. If this parameter is not specified, the user needs to enter the file names.|
1269