• 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## AudioViewPicker
392
393Provides APIs for selecting and saving audio clips. Before using the APIs of **AudioViewPicker**, you need to create an **AudioViewPicker** instance.
394
395**System capability**: SystemCapability.FileManagement.UserFileService
396
397### constructor<sup>12+</sup>
398
399constructor(context: Context)
400
401A 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).
402
403**Atomic service API**: This API can be used in atomic services since API version 12.
404
405**System capability**: SystemCapability.FileManagement.UserFileService
406
407**Parameters**
408| Name | Type   | Mandatory| Description                                                        |
409| ------- | ------- | ---- | ------------------------------------------------------------ |
410| 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).|
411
412**Example**
413
414```ts
415import { common } from '@kit.AbilityKit';
416import  { picker } from '@kit.CoreFileKit';
417@Entry
418@Component
419struct Index {
420  @State message: string = 'hello World';
421
422  build() {
423    Row() {
424      Column() {
425        Text(this.message)
426          .fontSize(50)
427          .fontWeight(FontWeight.Bold)
428          .onClick(()=>{
429            let context = getContext (this) as common.Context; // Ensure that getContext (this) returns UIAbilityContext.
430            let audioPicker = new picker.AudioViewPicker(context);
431          })
432      }
433      .width('100%')
434    }
435    .height('100%')
436  }
437}
438```
439### constructor<sup>12+</sup>
440
441constructor()
442
443A constructor used to create an **AudioViewPicker** instance. This constructor is not recommended due to the potential risk of operation failure.
444
445**Atomic service API**: This API can be used in atomic services since API version 12.
446
447**System capability**: SystemCapability.FileManagement.UserFileService
448
449**Example**
450
451```ts
452let audioPicker = new picker.AudioViewPicker(); // Construction without parameter is not recommended. There is a possibility that the AudioViewPicker instance fails to start.
453```
454
455### select
456
457select(option?: AudioSelectOptions): Promise&lt;Array&lt;string&gt;&gt;
458
459Starts 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**.
460
461> **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).
462
463**Atomic service API**: This API can be used in atomic services since API version 12.
464
465**System capability**: SystemCapability.FileManagement.UserFileService
466
467**Parameters**
468
469| Name | Type   | Mandatory| Description                      |
470| ------- | ------- | ---- | -------------------------- |
471| option | [AudioSelectOptions](#audioselectoptions) | No  | Options for selecting the audio clips. If this parameter is not specified, the **audioPicker** page is displayed by default. |
472
473**Return value**
474
475| Type                           | Description   |
476| ----------------------------- | :---- |
477| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the URIs of the audio clips selected.|
478
479**Example**
480
481```ts
482import { BusinessError } from '@kit.BasicServicesKit';
483import { common } from '@kit.AbilityKit';
484import  { picker } from '@kit.CoreFileKit';
485async function example13(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
486  try {
487    let audioSelectOptions = new picker.AudioSelectOptions();
488    let audioPicker = new picker.AudioViewPicker(context);
489    audioPicker.select(audioSelectOptions).then((audioSelectResult: Array<string>) => {
490      console.info('AudioViewPicker.select successfully, audioSelectResult uri: ' + JSON.stringify(audioSelectResult));
491    }).catch((err: BusinessError) => {
492      console.error('AudioViewPicker.select failed with err: ' + JSON.stringify(err));
493    });
494  } catch (error) {
495    let err: BusinessError = error as BusinessError;
496    console.error('AudioViewPicker failed with err: ' + JSON.stringify(err));
497  }
498}
499```
500
501### select
502
503select(option: AudioSelectOptions, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
504
505Starts 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**.
506
507> **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).
508
509**System capability**: SystemCapability.FileManagement.UserFileService
510
511**Parameters**
512
513| Name | Type   | Mandatory| Description                      |
514| ------- | ------- | ---- | -------------------------- |
515| option | [AudioSelectOptions](#audioselectoptions) | Yes  | Options for selecting audio clips.|
516| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;      | Yes  | Callback invoked to return the URIs of the audio clips selected.|
517
518**Example**
519
520```ts
521import { BusinessError } from '@kit.BasicServicesKit';
522import { common } from '@kit.AbilityKit';
523import  { picker } from '@kit.CoreFileKit';
524async function example14(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
525  try {
526    let audioSelectOptions = new picker.AudioSelectOptions();
527    let audioPicker = new picker.AudioViewPicker(context);
528    audioPicker.select(audioSelectOptions, (err: BusinessError, audioSelectResult: Array<string>) => {
529      if (err) {
530        console.error('AudioViewPicker.select failed with err: ' + JSON.stringify(err));
531        return;
532      }
533      console.info('AudioViewPicker.select successfully, audioSelectResult uri: ' + JSON.stringify(audioSelectResult));
534    });
535  } catch (error) {
536    let err: BusinessError = error as BusinessError;
537    console.error('AudioViewPicker failed with err: ' + JSON.stringify(err));
538  }
539}
540```
541
542### select
543
544select(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
545
546Starts an **audioPicker** page for the user to select one or more audio clips. This API uses an asynchronous callback to return the result.
547
548> **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).
549
550**System capability**: SystemCapability.FileManagement.UserFileService
551
552**Parameters**
553
554| Name | Type   | Mandatory| Description                      |
555| ------- | ------- | ---- | -------------------------- |
556| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;      | Yes  | Callback invoked to return the URIs of the audio clips selected.|
557
558**Example**
559
560```ts
561import { BusinessError } from '@kit.BasicServicesKit';
562import { common } from '@kit.AbilityKit';
563import  { picker } from '@kit.CoreFileKit';
564async function example15(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
565  try {
566    let audioPicker = new picker.AudioViewPicker(context);
567    audioPicker.select((err: BusinessError, audioSelectResult: Array<string>) => {
568      if (err) {
569        console.error('AudioViewPicker.select failed with err: ' + JSON.stringify(err));
570        return;
571      }
572      console.info('AudioViewPicker.select successfully, audioSelectResult uri: ' + JSON.stringify(audioSelectResult));
573    });
574  } catch (error) {
575    let err: BusinessError = error as BusinessError;
576    console.error('AudioViewPicker failed with err: ' + JSON.stringify(err));
577  }
578}
579```
580
581### save
582
583save(option?: AudioSaveOptions): Promise&lt;Array&lt;string&gt;&gt;
584
585Starts 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.
586
587> **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).
588
589**Atomic service API**: This API can be used in atomic services since API version 12.
590
591**System capability**: SystemCapability.FileManagement.UserFileService
592
593**Parameters**
594
595| Name | Type   | Mandatory| Description                      |
596| ------- | ------- | ---- | -------------------------- |
597| 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.|
598
599**Return value**
600
601| Type                           | Description   |
602| ----------------------------- | ---- |
603| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the URIs of the audio clips saved.|
604
605**Example**
606
607```ts
608import { BusinessError } from '@kit.BasicServicesKit';
609import { common } from '@kit.AbilityKit';
610import  { picker } from '@kit.CoreFileKit';
611async function example16(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
612  try {
613    let audioSaveOptions = new picker.AudioSaveOptions();
614    audioSaveOptions.newFileNames = ['AudioViewPicker01.mp3'];
615    let audioPicker = new picker.AudioViewPicker(context);
616    audioPicker.save(audioSaveOptions).then((audioSaveResult: Array<string>) => {
617      console.info('AudioViewPicker.save successfully, audioSaveResult uri: ' + JSON.stringify(audioSaveResult))
618    }).catch((err: BusinessError) => {
619      console.error('AudioViewPicker.save failed with err: ' + JSON.stringify(err));
620    });
621  } catch (error) {
622    let err: BusinessError = error as BusinessError;
623    console.error('AudioViewPicker failed with err: ' + JSON.stringify(err));
624  }
625}
626```
627
628### save
629
630save(option: AudioSaveOptions, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
631
632Starts 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.
633
634> **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).
635
636**System capability**: SystemCapability.FileManagement.UserFileService
637
638**Parameters**
639
640| Name | Type   | Mandatory| Description                      |
641| ------- | ------- | ---- | -------------------------- |
642| option | [AudioSaveOptions](#audiosaveoptions) | Yes  | Options for saving audio clips.|
643| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;      | Yes  | Callback invoked to return the URIs of the audio clips saved.|
644
645**Example**
646
647```ts
648import { BusinessError } from '@kit.BasicServicesKit';
649import { common } from '@kit.AbilityKit';
650import  { picker } from '@kit.CoreFileKit';
651async function example17(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
652  try {
653    let audioSaveOptions = new picker.AudioSaveOptions();
654    audioSaveOptions.newFileNames = ['AudioViewPicker02.mp3'];
655    let audioPicker = new picker.AudioViewPicker(context);
656    audioPicker.save(audioSaveOptions, (err: BusinessError, audioSaveResult: Array<string>) => {
657      if (err) {
658        console.error('AudioViewPicker.save failed with err: ' + JSON.stringify(err));
659        return;
660      }
661      console.info('AudioViewPicker.save successfully, audioSaveResult uri: ' + JSON.stringify(audioSaveResult));
662    });
663  } catch (error) {
664    let err: BusinessError = error as BusinessError;
665    console.error('AudioViewPicker failed with err: ' + JSON.stringify(err));
666  }
667}
668```
669
670### save
671
672save(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
673
674Starts 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.
675
676> **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).
677
678**System capability**: SystemCapability.FileManagement.UserFileService
679
680**Parameters**
681
682| Name | Type   | Mandatory| Description                      |
683| ------- | ------- | ---- | -------------------------- |
684| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;      | Yes  | Callback invoked to return the URIs of the audio clips saved.|
685
686**Example**
687
688```ts
689import { BusinessError } from '@kit.BasicServicesKit';
690import { common } from '@kit.AbilityKit';
691import  { picker } from '@kit.CoreFileKit';
692async function example18(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
693  try {
694    let audioPicker = new picker.AudioViewPicker(context);
695    audioPicker.save((err: BusinessError, audioSaveResult: Array<string>) => {
696      if (err) {
697        console.error('AudioViewPicker.save failed with err: ' + JSON.stringify(err));
698        return;
699      }
700      console.info('AudioViewPicker.save successfully, audioSaveResult uri: ' + JSON.stringify(audioSaveResult));
701    });
702  } catch (error) {
703    let err: BusinessError = error as BusinessError;
704    console.error('AudioViewPicker failed with err: ' + JSON.stringify(err));
705  }
706}
707```
708
709## DocumentSelectMode<sup>11+</sup>
710
711Enumerates the types of files that can be selected by Picker.
712
713**Atomic service API**: This API can be used in atomic services since API version 12.
714
715**System capability**: SystemCapability.FileManagement.UserFileService.FolderSelection
716
717| Name |  Value|  Description|
718| ----- |  ---- | ---- |
719| FILE  | 0  | File. |
720| FOLDER | 1  | Folder. |
721| MIXED | 2  | File and folder. |
722
723## DocumentSelectOptions
724
725Defines the options for selecting documents.
726
727**Atomic service API**: This API can be used in atomic services since API version 12.
728
729**System capability**: SystemCapability.FileManagement.UserFileService
730
731| Name                   | Type                                         | Mandatory| Description                                      |
732| :---------------------- |---------------------------------------------| ---- |------------------------------------------|
733| 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 |
734| defaultFilePathUri<sup>10+</sup>    | string                                      | No  | Path of the documents or folder to select.                           |
735| fileSuffixFilters<sup>10+</sup>     | Array&lt;string&gt;                         | No  | File name extension types of the documents to select. <br/>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. <br/>This parameter is available only to the devices that have the required system capability. By default, all documents are selected. <br/>**System capability**: SystemCapability.FileManagement.UserFileService  |
736| selectMode<sup>11+</sup>         | [DocumentSelectMode](#documentselectmode11) | No  | Resource types that can be selected, for example, file, folder, or both. <br/>This parameter is available only to the devices that have the required system capability. <br/>The default value is **File**.<br/>**System capability**: SystemCapability.FileManagement.UserFileService.FolderSelection |
737| authMode<sup>12+</sup>    | boolean                              | No  | Whether to start Picker.<br>Default value: **false**. <br/>If **authMode** is **true**, **defaultFilePathUri** is mandatory, which specifies the URI of the file allowed to access. <br/>This parameter is available only to the devices that have the required system capability.<br>**System capability**: SystemCapability.FileManagement.UserFileService.FolderSelection |
738
739## DocumentPickerMode<sup>12+</sup>
740
741Enumerates the types of files that can be selected by Picker.
742
743**Atomic service API**: This API can be used in atomic services since API version 12.
744
745**System capability**: SystemCapability.FileManagement.UserFileService
746
747| Name |  Value|  Description|
748| ----- |  ---- | ---- |
749| DEFAULT  | 0  | Standard mode.|
750| DOWNLOAD | 1  | Download mode.|
751
752## DocumentSaveOptions
753
754Defines the options for saving documents.
755
756**Atomic service API**: This API can be used in atomic services since API version 12.
757
758**System capability**: SystemCapability.FileManagement.UserFileService
759
760| Name                   | Type               | Mandatory|  Description                          |
761| ----------------------- | ------------------- | ---- | ---------------------------- |
762| newFileNames            | Array&lt;string&gt;    | No  | Names of the documents to save. If this parameter is not specified, the user needs to enter the document names.  |
763| defaultFilePathUri<sup>10+</sup>    | string  | No  | Path of the documents or folder to save. |
764| fileSuffixChoices<sup>10+</sup>     | Array&lt;string&gt; | No  | File name extensions of the documents to save.<br/>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.|
765| pickerMode<sup>12+</sup>     | [DocumentPickerMode](#documentpickermode12) | No  | Mode for starting Picker.<br>Default value: **DEFAULT**<br/>If **pickerMode** is **DOWNLOAD**, the settings of **newFileNames**, **defaultFilePathUri**, and **fileSuffixChoices** do not take effect. |
766
767## AudioSelectOptions
768
769Defines the options for selecting audio clips.
770
771**Atomic service API**: This API can be used in atomic services since API version 12.
772
773**System capability**: SystemCapability.FileManagement.UserFileService
774| Name                   | Type                                         | Mandatory| Description                                      |
775| :---------------------- |---------------------------------------------| ---- |------------------------------------------|
776| 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|
777
778## AudioSaveOptions
779
780Defines the options for saving audio clips.
781
782**Atomic service API**: This API can be used in atomic services since API version 12.
783
784**System capability**: SystemCapability.FileManagement.UserFileService
785
786| Name                   | Type               | Mandatory|  Description                          |
787| ----------------------- | ------------------- | ---- | ---------------------------- |
788| newFileNames              | Array&lt;string&gt;    | No | Names of the audio clips to save. If this parameter is not specified, the user needs to enter the file names.|
789
790## PhotoViewPicker<sup>(deprecated)</sup>
791
792Provides 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.
793
794> **NOTE**
795>
796> 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.
797
798**System capability**: SystemCapability.FileManagement.UserFileService
799
800### constructor<sup>12+</sup>
801
802constructor(context: Context)
803
804**System capability**: SystemCapability.FileManagement.UserFileService
805
806A 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).
807
808**Example**
809
810```ts
811import { common } from '@kit.AbilityKit';
812import  { picker } from '@kit.CoreFileKit';
813@Entry
814@Component
815struct Index {
816  @State message: string = 'hello World';
817
818  build() {
819    Row() {
820      Column() {
821        Text(this.message)
822          .fontSize(50)
823          .fontWeight(FontWeight.Bold)
824          .onClick(()=>{
825            let context = getContext (this) as common.Context; // Ensure that getContext (this) returns UIAbilityContext.
826            let photoPicker = new picker.PhotoViewPicker(context);
827          })
828      }
829      .width('100%')
830    }
831    .height('100%')
832  }
833}
834```
835
836### constructor<sup>12+</sup>
837
838constructor()
839
840**Atomic service API**: This API can be used in atomic services since API version 12.
841
842**System capability**: SystemCapability.FileManagement.UserFileService
843
844A constructor used to create a **PhotoViewPicker** instance. This constructor is not recommended due to the potential risk of operation failure.
845
846**Example**
847
848```ts
849let photoPicker = new picker.PhotoViewPicker(); // Construction without parameter is not recommended. There is a possibility that the PhotoViewPicker instance fails to start.
850```
851
852### select<sup>(deprecated)</sup>
853
854select(option?: PhotoSelectOptions): Promise&lt;PhotoSelectResult&gt;
855
856Starts 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.
857
858> **NOTE**
859>
860> 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.
861
862> **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).
863
864**Atomic service API**: This API can be used in atomic services since API version 11.
865
866**System capability**: SystemCapability.FileManagement.UserFileService
867
868**Parameters**
869
870| Name | Type   | Mandatory| Description                      |
871| ------- | ------- | ---- | -------------------------- |
872| option | [PhotoSelectOptions](#photoselectoptionsdeprecated) | No  | Options for selecting images/videos. By default, images and videos are selected, and the maximum number of files that can be selected is 50.|
873
874**Return value**
875
876| Type                           | Description   |
877| ----------------------------- | :---- |
878| Promise&lt;[PhotoSelectResult](#photoselectresultdeprecated)&gt; | Promise used to return a **PhotoSelectResult** object.|
879
880**Example**
881
882```ts
883import { BusinessError } from '@kit.BasicServicesKit';
884import { common } from '@kit.AbilityKit';
885import  { picker } from '@kit.CoreFileKit';
886async function example01(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
887  try {
888    let photoSelectOptions = new picker.PhotoSelectOptions();
889    photoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE;
890    photoSelectOptions.maxSelectNumber = 5;
891    let photoPicker = new picker.PhotoViewPicker(context);
892    photoPicker.select(photoSelectOptions).then((photoSelectResult: picker.PhotoSelectResult) => {
893      console.info('PhotoViewPicker.select successfully, photoSelectResult uri: ' + JSON.stringify(photoSelectResult));
894    }).catch((err: BusinessError) => {
895      console.error('PhotoViewPicker.select failed with err: ' + JSON.stringify(err));
896    });
897  } catch (error) {
898    let err: BusinessError = error as BusinessError;
899    console.error('PhotoViewPicker failed with err: ' + JSON.stringify(err));
900  }
901}
902```
903
904### select<sup>(deprecated)</sup>
905
906select(option: PhotoSelectOptions, callback: AsyncCallback&lt;PhotoSelectResult&gt;): void
907
908Starts 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.
909
910> **NOTE**
911>
912> 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.
913
914> **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).
915
916**Atomic service API**: This API can be used in atomic services since API version 11.
917
918**System capability**: SystemCapability.FileManagement.UserFileService
919
920**Parameters**
921
922| Name | Type   | Mandatory| Description                      |
923| ------- | ------- | ---- | -------------------------- |
924| option | [PhotoSelectOptions](#photoselectoptionsdeprecated) | Yes  | Options for selecting images/videos.|
925| callback | AsyncCallback&lt;[PhotoSelectResult](#photoselectresultdeprecated)&gt;      | Yes  | Callback invoked to return a **PhotoSelectResult** object.|
926
927**Example**
928
929```ts
930import { BusinessError } from '@kit.BasicServicesKit';
931import { common } from '@kit.AbilityKit';
932import  { picker } from '@kit.CoreFileKit';
933async function example02(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
934  try {
935    let photoSelectOptions = new picker.PhotoSelectOptions();
936    photoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE;
937    photoSelectOptions.maxSelectNumber = 5;
938    let photoPicker = new picker.PhotoViewPicker(context);
939    photoPicker.select(photoSelectOptions, (err: BusinessError, photoSelectResult: picker.PhotoSelectResult) => {
940      if (err) {
941        console.error('PhotoViewPicker.select failed with err: ' + JSON.stringify(err));
942        return;
943      }
944      console.info('PhotoViewPicker.select successfully, photoSelectResult uri: ' + JSON.stringify(photoSelectResult));
945    });
946  } catch (error) {
947    let err: BusinessError = error as BusinessError;
948    console.error('PhotoViewPicker failed with err: ' + JSON.stringify(err));
949  }
950}
951```
952
953### select<sup>(deprecated)</sup>
954
955select(callback: AsyncCallback&lt;PhotoSelectResult&gt;): void
956
957Starts a **photoPicker** page for the user to select one or more images/videos. This API uses an asynchronous callback to return the result.
958
959> **NOTE**
960>
961> 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.
962
963> **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).
964
965**Atomic service API**: This API can be used in atomic services since API version 11.
966
967**System capability**: SystemCapability.FileManagement.UserFileService
968
969**Parameters**
970
971| Name | Type   | Mandatory| Description                      |
972| ------- | ------- | ---- | -------------------------- |
973| callback | AsyncCallback&lt;[PhotoSelectResult](#photoselectresultdeprecated)&gt;      | Yes  | Callback invoked to return a **PhotoSelectResult** object.|
974
975**Example**
976
977```ts
978import { BusinessError } from '@kit.BasicServicesKit';
979import { common } from '@kit.AbilityKit';
980import  { picker } from '@kit.CoreFileKit';
981async function example03(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
982  try {
983    let photoPicker = new picker.PhotoViewPicker(context);
984    photoPicker.select((err: BusinessError, photoSelectResult: picker.PhotoSelectResult) => {
985      if (err) {
986        console.error('PhotoViewPicker.select failed with err: ' + JSON.stringify(err));
987        return;
988      }
989      console.info('PhotoViewPicker.select successfully, photoSelectResult uri: ' + JSON.stringify(photoSelectResult));
990    });
991  } catch (error) {
992    let err: BusinessError = error as BusinessError;
993    console.error('PhotoViewPicker failed with err: ' + JSON.stringify(err));
994  }
995}
996```
997
998### save<sup>(deprecated)</sup>
999
1000save(option?: PhotoSaveOptions): Promise&lt;Array&lt;string&gt;&gt;
1001
1002Starts 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.
1003
1004> **NOTE**
1005>
1006> 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.
1007
1008> **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).
1009
1010**System capability**: SystemCapability.FileManagement.UserFileService
1011
1012**Parameters**
1013
1014| Name | Type   | Mandatory| Description                      |
1015| ------- | ------- | ---- | -------------------------- |
1016| option | [PhotoSaveOptions](#photosaveoptionsdeprecated) | 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.|
1017
1018**Return value**
1019
1020| Type                           | Description   |
1021| ----------------------------- | :---- |
1022| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the URIs of the files saved.|
1023
1024**Example**
1025
1026```ts
1027import { BusinessError } from '@kit.BasicServicesKit';
1028import { common } from '@kit.AbilityKit';
1029import  { picker } from '@kit.CoreFileKit';
1030async function example04(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
1031  try {
1032    let photoSaveOptions = new picker.PhotoSaveOptions();
1033    photoSaveOptions.newFileNames = ['PhotoViewPicker01.jpg', 'PhotoViewPicker01.mp4'];
1034    let photoPicker = new picker.PhotoViewPicker(context);
1035    photoPicker.save(photoSaveOptions).then((photoSaveResult: Array<string>) => {
1036      console.info('PhotoViewPicker.save successfully, photoSaveResult uri: ' + JSON.stringify(photoSaveResult));
1037    }).catch((err: BusinessError) => {
1038      console.error('PhotoViewPicker.save failed with err: ' + JSON.stringify(err));
1039    });
1040  } catch (error) {
1041    let err: BusinessError = error as BusinessError;
1042      console.error('PhotoViewPicker failed with err: ' + JSON.stringify(err));
1043  }
1044}
1045```
1046
1047### save<sup>(deprecated)</sup>
1048
1049save(option: PhotoSaveOptions, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
1050
1051Starts 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.
1052
1053> **NOTE**
1054>
1055> 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.
1056
1057> **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).
1058
1059**System capability**: SystemCapability.FileManagement.UserFileService
1060
1061**Parameters**
1062
1063| Name | Type   | Mandatory| Description                      |
1064| ------- | ------- | ---- | -------------------------- |
1065| option | [PhotoSaveOptions](#photosaveoptionsdeprecated) | Yes  | Options for saving images/videos.|
1066| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;      | Yes  | Callback invoked to return the URIs of the files saved.|
1067
1068**Example**
1069
1070```ts
1071import { BusinessError } from '@kit.BasicServicesKit';
1072import { common } from '@kit.AbilityKit';
1073import  { picker } from '@kit.CoreFileKit';
1074async function example05(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
1075  try {
1076    let photoSaveOptions = new picker.PhotoSaveOptions();
1077    photoSaveOptions.newFileNames = ['PhotoViewPicker02.jpg','PhotoViewPicker02.mp4'];
1078    let photoPicker = new picker.PhotoViewPicker(context);
1079    photoPicker.save(photoSaveOptions, (err: BusinessError, photoSaveResult: Array<string>) => {
1080      if (err) {
1081        console.error('PhotoViewPicker.save failed with err: ' + JSON.stringify(err));
1082        return;
1083      }
1084      console.info('PhotoViewPicker.save successfully, photoSaveResult uri: ' + JSON.stringify(photoSaveResult));
1085    });
1086  } catch (error) {
1087    let err: BusinessError = error as BusinessError;
1088    console.error('PhotoViewPicker failed with err: ' + JSON.stringify(err));
1089  }
1090}
1091```
1092
1093### save<sup>(deprecated)</sup>
1094
1095save(callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
1096
1097Starts a **photoPicker** page for the user to save one or more images/videos. This API uses an asynchronous callback to return the result.
1098
1099> **NOTE**
1100>
1101> 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.
1102
1103> **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).
1104
1105**System capability**: SystemCapability.FileManagement.UserFileService
1106
1107**Parameters**
1108
1109| Name | Type   | Mandatory| Description                      |
1110| ------- | ------- | ---- | -------------------------- |
1111| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;      | Yes  | Callback invoked to return the URIs of the files saved.|
1112
1113**Example**
1114
1115```ts
1116import { BusinessError } from '@kit.BasicServicesKit';
1117import { common } from '@kit.AbilityKit';
1118import  { picker } from '@kit.CoreFileKit';
1119async function example06(context: common.Context) {// Ensure that context is converted from UIAbilityContext.
1120  try {
1121    let photoPicker = new picker.PhotoViewPicker(context);
1122    photoPicker.save((err: BusinessError, photoSaveResult: Array<string>) => {
1123      if (err) {
1124        console.error('PhotoViewPicker.save failed with err: ' + JSON.stringify(err));
1125        return;
1126      }
1127      console.info('PhotoViewPicker.save successfully, photoSaveResult uri: ' + JSON.stringify(photoSaveResult));
1128    });
1129  } catch (error) {
1130    let err: BusinessError = error as BusinessError;
1131    console.error('PhotoViewPicker failed with err: ' + JSON.stringify(err));
1132  }
1133}
1134```
1135
1136## PhotoViewMIMETypes<sup>(deprecated)</sup>
1137
1138Enumerates the media file types that can be selected.
1139
1140> **NOTE**
1141>
1142> 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.
1143
1144**Atomic service API**: This API can be used in atomic services since API version 11.
1145
1146**System capability**: SystemCapability.FileManagement.UserFileService
1147
1148| Name |  Value|  Description|
1149| ----- |  ---- | ---- |
1150| IMAGE_TYPE  |  'image/*' | Image. |
1151| VIDEO_TYPE |  'video/*' | Video. |
1152| IMAGE_VIDEO_TYPE |  '\*/*' | Image and video. |
1153
1154## PhotoSelectOptions<sup>(deprecated)</sup>
1155
1156Defines the options for selecting images/videos.
1157
1158> **NOTE**
1159>
1160> 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.
1161
1162**Atomic service API**: This API can be used in atomic services since API version 11.
1163
1164**System capability**: SystemCapability.FileManagement.UserFileService
1165
1166| Name                   | Type               | Mandatory| Description                         |
1167| ----------------------- | ------------------- | ---- | -------------------------------- |
1168| MIMEType              | [PhotoViewMIMETypes](#photoviewmimetypesdeprecated)   | No  | Types of the media files to select. **IMAGE_VIDEO_TYPE** is used by default. |
1169| maxSelectNumber       | number | No  | Maximum number of media files to select. The default value is **50**, and the maximum value is **500**.     |
1170
1171## PhotoSelectResult<sup>(deprecated)</sup>
1172
1173Defines information about the images/videos selected.
1174
1175> **NOTE**
1176>
1177> 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.
1178
1179**Atomic service API**: This API can be used in atomic services since API version 11.
1180
1181**System capability**: SystemCapability.FileManagement.UserFileService
1182
1183| Name                   | Type               | Mandatory| Description                          |
1184| ----------------------- | ------------------- | ----| ------------------------------ |
1185| photoUris        | Array&lt;string&gt;    | Yes  | Array of the URIs of the images/videos 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). |
1186| 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. |
1187
1188## PhotoSaveOptions<sup>(deprecated)</sup>
1189
1190Defines the options for saving images or videos.
1191
1192> **NOTE**
1193>
1194> This API is supported since API version 9 and deprecated since API version 12. There is no substitute API.
1195
1196**System capability**: SystemCapability.FileManagement.UserFileService
1197
1198| Name                   | Type               | Mandatory|  Description                          |
1199| ----------------------- | ------------------- | ---- | ---------------------------- |
1200| newFileNames              | Array&lt;string&gt;    | No | Names of the files to save. If this parameter is not specified, the user needs to enter the file names.|
1201