• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit CoreFileKit
19 */
20
21import type { AsyncCallback, Callback } from './@ohos.base';
22import type Context from './application/Context';
23import image from './@ohos.multimedia.image';
24import dataSharePredicates from './@ohos.data.dataSharePredicates';
25
26/**
27 * @namespace userFileManager
28 * @syscap SystemCapability.FileManagement.UserFileManager.Core
29 * @systemapi
30 * @since 9
31 */
32declare namespace userFileManager {
33  /**
34   * Returns an instance of UserFileManager
35   *
36   * @param { Context } context - Hap context information
37   * @returns { UserFileManager } Instance of UserFileManager
38   * @syscap SystemCapability.FileManagement.UserFileManager.Core
39   * @systemapi
40   * @StageModelOnly
41   * @since 9
42   */
43  function getUserFileMgr(context: Context): UserFileManager;
44
45  /**
46   * Enumeration types for different kinds of Files
47   *
48   * @enum { number } FileType
49   * @syscap SystemCapability.FileManagement.UserFileManager.Core
50   * @systemapi
51   * @since 9
52   */
53  enum FileType {
54    /**
55     * Image file type
56     *
57     * @syscap SystemCapability.FileManagement.UserFileManager.Core
58     * @systemapi
59     * @since 9
60     */
61    IMAGE = 1,
62    /**
63     * Video file type
64     *
65     * @syscap SystemCapability.FileManagement.UserFileManager.Core
66     * @systemapi
67     * @since 9
68     */
69    VIDEO,
70    /**
71     * Audio file type
72     *
73     * @syscap SystemCapability.FileManagement.UserFileManager.Core
74     * @systemapi
75     * @since 9
76     */
77    AUDIO
78  }
79
80  /**
81   * Enumeration types for different types of FileAsset
82   *
83   * @enum { number } PhotoSubType
84   * @syscap SystemCapability.FileManagement.UserFileManager.Core
85   * @systemapi
86   * @since 10
87   */
88  enum PhotoSubType {
89    /**
90     * Default Photo Type
91     *
92     * @syscap SystemCapability.FileManagement.UserFileManager.Core
93     * @systemapi
94     * @since 10
95     */
96    DEFAULT,
97    /**
98     * Screenshot Photo Type
99     *
100     * @syscap SystemCapability.FileManagement.UserFileManager.Core
101     * @systemapi
102     * @since 10
103     */
104    SCREENSHOT,
105    /**
106     * Camera Photo Type
107     *
108     * @syscap SystemCapability.FileManagement.UserFileManager.Core
109     * @systemapi
110     * @since 10
111     */
112    CAMERA
113  }
114
115  /**
116   * File position
117   *
118   * @enum { number } File position, which indicates the file is on local device or cloud
119   * @syscap SystemCapability.FileManagement.UserFileManager.Core
120   * @systemapi
121   * @since 10
122   */
123  enum PositionType {
124    /**
125     * File exists only on local device
126     *
127     * @syscap SystemCapability.FileManagement.UserFileManager.Core
128     * @systemapi
129     * @since 10
130     */
131    LOCAL = 1,
132    /**
133     * File exists only on cloud
134     *
135     * @syscap SystemCapability.FileManagement.UserFileManager.Core
136     * @systemapi
137     * @since 10
138     */
139    CLOUD,
140    /**
141     * File exists on both local and cloud
142     *
143     * @syscap SystemCapability.FileManagement.UserFileManager.Core
144     * @systemapi
145     * @since 10
146     */
147    BOTH
148  }
149
150  /**
151   * Indicates the type of file asset member.
152   *
153   * @typedef { number | string | boolean } MemberType
154   * @syscap SystemCapability.FileManagement.UserFileManager.Core
155   * @systemapi
156   * @since 9
157   */
158  type MemberType = number | string | boolean;
159
160  /**
161   * Indicates the type of notify event.
162   *
163   * @typedef { 'deviceChange' | 'albumChange' | 'imageChange' | 'audioChange' | 'videoChange' | 'remoteFileChange' } ChangeEvent
164   * @syscap SystemCapability.FileManagement.UserFileManager.Core
165   * @systemapi
166   * @since 9
167   */
168  type ChangeEvent =
169    'deviceChange'
170    | 'albumChange'
171    | 'imageChange'
172    | 'audioChange'
173    | 'videoChange'
174    | 'remoteFileChange';
175
176  /**
177   * Provides methods to encapsulate file attributes.
178   *
179   * @interface FileAsset
180   * @syscap SystemCapability.FileManagement.UserFileManager.Core
181   * @systemapi
182   * @since 9
183   */
184  interface FileAsset {
185    /**
186     * URI of the file.
187     *
188     * @type { string }
189     * @syscap SystemCapability.FileManagement.UserFileManager.Core
190     * @systemapi
191     * @since 9
192     */
193    readonly uri: string;
194    /**
195     * File type, for example, IMAGE, VIDEO, AUDIO
196     *
197     * @type { FileType }
198     * @syscap SystemCapability.FileManagement.UserFileManager.Core
199     * @systemapi
200     * @since 9
201     */
202    readonly fileType: FileType;
203    /**
204     * Display name (with a file name extension) of the file.
205     *
206     * @type { string }
207     * @syscap SystemCapability.FileManagement.UserFileManager.Core
208     * @systemapi
209     * @since 9
210     */
211    displayName: string;
212    /**
213     * Return the fileAsset member parameter.
214     *
215     * @param { string } member - The name of the parameter. for example : get(ImageVideoKey.URI)
216     * @returns { MemberType }
217     * @syscap SystemCapability.FileManagement.UserFileManager.Core
218     * @systemapi
219     * @since 9
220     */
221    get(member: string): MemberType;
222    /**
223     * Set the fileAsset member parameter.
224     *
225     * @param { string } member - The name of the parameter
226     * @param { string } value - The value of the parameter.
227     * @syscap SystemCapability.FileManagement.UserFileManager.Core
228     * @systemapi
229     * @since 9
230     * @example : Set(ImageVideoKey.TITLE, "newTitle"), call commitModify after set value
231     */
232    set(member: string, value: string): void;
233    /**
234     * Modify meta data where the file is located.
235     *
236     * @permission ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO
237     * @param { AsyncCallback<void> } callback - No value will be returned.
238     * @syscap SystemCapability.FileManagement.UserFileManager.Core
239     * @systemapi
240     * @since 9
241     */
242    commitModify(callback: AsyncCallback<void>): void;
243    /**
244     * Modify meta data where the file is located.
245     *
246     * @permission ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO
247     * @returns { Promise<void> } Return promise
248     * @syscap SystemCapability.FileManagement.UserFileManager.Core
249     * @systemapi
250     * @since 9
251     */
252    commitModify(): Promise<void>;
253    /**
254     * Open local file.
255     *
256     * @permission ohos.permission.READ_IMAGEVIDEO or ohos.permission.READ_AUDIO or ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO
257     * @param { string } mode - Mode for open, for example: rw, r, w.
258     * @param { AsyncCallback<number> } callback - Callback return the fd of the file.
259     * @syscap SystemCapability.FileManagement.UserFileManager.Core
260     * @systemapi
261     * @since 9
262     */
263    open(mode: string, callback: AsyncCallback<number>): void;
264    /**
265     * Open local file.
266     *
267     * @permission ohos.permission.READ_IMAGEVIDEO or ohos.permission.READ_AUDIO or ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO
268     * @param { string } mode - Mode for open, for example: rw, r, w.
269     * @returns { Promise<number> } Return promise
270     * @syscap SystemCapability.FileManagement.UserFileManager.Core
271     * @systemapi
272     * @since 9
273     */
274    open(mode: string): Promise<number>;
275    /**
276     * Close the file is located.
277     *
278     * @param { number } fd - Fd of the file which had been opened
279     * @param { AsyncCallback<void> } callback - No value will be returned.
280     * @syscap SystemCapability.FileManagement.UserFileManager.Core
281     * @systemapi
282     * @since 9
283     */
284    close(fd: number, callback: AsyncCallback<void>): void;
285    /**
286     * Close the file is located.
287     *
288     * @param { number } fd - Fd of the file which had been opened
289     * @returns { Promise<void> } Return promise
290     * @syscap SystemCapability.FileManagement.UserFileManager.Core
291     * @systemapi
292     * @since 9
293     */
294    close(fd: number): Promise<void>;
295    /**
296     * Get thumbnail of the file when the file is located.
297     *
298     * @permission ohos.permission.READ_IMAGEVIDEO or ohos.permission.READ_AUDIO
299     * @param { AsyncCallback<image.PixelMap> } callback - Callback used to return the thumbnail's pixelMap.
300     * @syscap SystemCapability.FileManagement.UserFileManager.Core
301     * @systemapi
302     * @since 9
303     */
304    getThumbnail(callback: AsyncCallback<image.PixelMap>): void;
305    /**
306     * Get thumbnail of the file when the file is located.
307     *
308     * @permission ohos.permission.READ_IMAGEVIDEO or ohos.permission.READ_AUDIO
309     * @param { image.Size } size - Thumbnail's size
310     * @param { AsyncCallback<image.PixelMap> } callback - Callback used to return the thumbnail's pixelMap.
311     * @syscap SystemCapability.FileManagement.UserFileManager.Core
312     * @systemapi
313     * @since 9
314     */
315    getThumbnail(size: image.Size, callback: AsyncCallback<image.PixelMap>): void;
316    /**
317     * Get thumbnail of the file when the file is located.
318     *
319     * @permission ohos.permission.READ_IMAGEVIDEO or ohos.permission.READ_AUDIO
320     * @param { image.Size } size - Thumbnail's size
321     * @returns { Promise<image.PixelMap> } Return promise
322     * @syscap SystemCapability.FileManagement.UserFileManager.Core
323     * @systemapi
324     * @since 9
325     */
326    getThumbnail(size?: image.Size): Promise<image.PixelMap>;
327    /**
328     * Set favorite for the file when the file is located.
329     *
330     * @permission ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO
331     * @param { boolean } isFavorite - True is favorite file, false is not favorite file
332     * @param { AsyncCallback<void> } callback - Callback used to return, No value is returned.
333     * @syscap SystemCapability.FileManagement.UserFileManager.Core
334     * @systemapi
335     * @since 9
336     */
337    favorite(isFavorite: boolean, callback: AsyncCallback<void>): void;
338    /**
339     * Set favorite for the file when the file is located.
340     *
341     * @permission ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO
342     * @param { boolean } isFavorite - isFavorite True is favorite file, false is not favorite file
343     * @returns { Promise<void> } Return promise
344     * @syscap SystemCapability.FileManagement.UserFileManager.Core
345     * @systemapi
346     * @since 9
347     */
348    favorite(isFavorite: boolean): Promise<void>;
349    /**
350     * Set file hidden state.
351     *
352     * @permission ohos.permission.WRITE_IMAGEVIDEO
353     * @param { boolean } hiddenState - true: Put the asset into hidden album; false: Recover the asset from hidden album.
354     * @param { AsyncCallback<void> } callback - Return void.
355     * @throws { BusinessError } 202 - Called by non-system application.
356     * @throws { BusinessError } 13900020 - if parameter is invalid
357     * @syscap SystemCapability.FileManagement.UserFileManager.Core
358     * @systemapi
359     * @since 10
360     */
361    setHidden(hiddenState: boolean, callback: AsyncCallback<void>): void;
362    /**
363     * Set file hidden state.
364     *
365     * @permission ohos.permission.WRITE_IMAGEVIDEO
366     * @param { boolean } hiddenState - true: Put the asset into hidden album; false: Recover the asset from hidden album.
367     * @returns { Promise<void> } Returns the promise
368     * @throws { BusinessError } 202 - Called by non-system application.
369     * @throws { BusinessError } 13900020 - if parameter is invalid
370     * @syscap SystemCapability.FileManagement.UserFileManager.Core
371     * @systemapi
372     * @since 10
373     */
374    setHidden(hiddenState: boolean): Promise<void>;
375    /**
376     * Set user comment info to the asset.
377     *
378     * @permission ohos.permission.WRITE_IMAGEVIDEO
379     * @param { string } userComment - user comment info
380     * @param { AsyncCallback<void> } callback - Returns void.
381     * @throws { BusinessError } 202 - Called by non-system application.
382     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
383     * <br>2. Incorrect parameter types; 3. Parameter verification failed.
384     * @syscap SystemCapability.FileManagement.UserFileManager.Core
385     * @systemapi
386     * @since 10
387     */
388    setUserComment(userComment: string, callback: AsyncCallback<void>): void;
389    /**
390     * Set user comment info to the asset.
391     *
392     * @permission ohos.permission.WRITE_IMAGEVIDEO
393     * @param { string } userComment - user comment info
394     * @returns { Promise<void> } Returns void
395     * @throws { BusinessError } 202 - Called by non-system application.
396     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
397     * <br>2. Incorrect parameter types; 3. Parameter verification failed.
398     * @syscap SystemCapability.FileManagement.UserFileManager.Core
399     * @systemapi
400     * @since 10
401     */
402    setUserComment(userComment: string): Promise<void>;
403    /**
404     * Get exif info of the asset.
405     *
406     * @permission ohos.permission.READ_IMAGEVIDEO
407     * @param { AsyncCallback<string> } callback - Returns exif info into a json string
408     * @throws { BusinessError } 202 - Called by non-system application.
409     * @syscap SystemCapability.FileManagement.UserFileManager.Core
410     * @systemapi
411     * @since 10
412     */
413    getExif(callback: AsyncCallback<string>): void;
414    /**
415     * Get exif info of the asset.
416     *
417     * @permission ohos.permission.READ_IMAGEVIDEO
418     * @returns { Promise<string> } Returns exif info into a json string
419     * @throws { BusinessError } 202 - Called by non-system application.
420     * @syscap SystemCapability.FileManagement.UserFileManager.Core
421     * @systemapi
422     * @since 10
423     */
424    getExif(): Promise<string>;
425  }
426
427  /**
428   * Describes AUDIO TYPE FetchOptions's predicate
429   *
430   * @enum { string } AudioKey
431   * @syscap SystemCapability.FileManagement.UserFileManager.Core
432   * @systemapi
433   * @since 9
434   */
435  enum AudioKey {
436    /**
437     * File uri, read only
438     *
439     * @syscap SystemCapability.FileManagement.UserFileManager.Core
440     * @systemapi
441     * @since 9
442     */
443    URI,
444    /**
445     * File name
446     *
447     * @syscap SystemCapability.FileManagement.UserFileManager.Core
448     * @systemapi
449     * @since 9
450     */
451    DISPLAY_NAME,
452    /**
453     * Date of the file creation, read only
454     *
455     * @syscap SystemCapability.FileManagement.UserFileManager.Core
456     * @systemapi
457     * @since 9
458     */
459    DATE_ADDED,
460    /**
461     * Modify date of the file, read only
462     *
463     * @syscap SystemCapability.FileManagement.UserFileManager.Core
464     * @systemapi
465     * @since 9
466     */
467    DATE_MODIFIED,
468    /**
469     * Title of the file, read only
470     *
471     * @syscap SystemCapability.FileManagement.UserFileManager.Core
472     * @systemapi
473     * @since 9
474     */
475    TITLE,
476    /**
477     * Artist of the audio file, read only
478     *
479     * @syscap SystemCapability.FileManagement.UserFileManager.Core
480     * @systemapi
481     * @since 9
482     */
483    ARTIST,
484    /**
485     * Audio album of the audio file, read only
486     *
487     * @syscap SystemCapability.FileManagement.UserFileManager.Core
488     * @systemapi
489     * @since 9
490     */
491    AUDIOALBUM,
492    /**
493     * Duration of the audio file, read only
494     *
495     * @syscap SystemCapability.FileManagement.UserFileManager.Core
496     * @systemapi
497     * @since 9
498     */
499    DURATION,
500    /**
501     * Favorite state of the file, read only
502     *
503     * @syscap SystemCapability.FileManagement.UserFileManager.Core
504     * @systemapi
505     * @since 9
506     */
507    FAVORITE
508  }
509
510  /**
511   * Describes Image, Video TYPE FetchOptions's predicate
512   *
513   * @enum { string } ImageVideoKey
514   * @syscap SystemCapability.FileManagement.UserFileManager.Core
515   * @systemapi
516   * @since 9
517   */
518  enum ImageVideoKey {
519    /**
520     * File uri, read only
521     *
522     * @syscap SystemCapability.FileManagement.UserFileManager.Core
523     * @systemapi
524     * @since 9
525     */
526    URI,
527    /**
528     * File type of the Asset, read only
529     *
530     * @syscap SystemCapability.FileManagement.UserFileManager.Core
531     * @systemapi
532     * @since 9
533     */
534    FILE_TYPE,
535    /**
536     * File name
537     *
538     * @syscap SystemCapability.FileManagement.UserFileManager.Core
539     * @systemapi
540     * @since 9
541     */
542    DISPLAY_NAME,
543    /**
544     * Date of the file creation, read only
545     *
546     * @syscap SystemCapability.FileManagement.UserFileManager.Core
547     * @systemapi
548     * @since 9
549     */
550    DATE_ADDED,
551    /**
552     * Modify date of the file, read only
553     *
554     * @syscap SystemCapability.FileManagement.UserFileManager.Core
555     * @systemapi
556     * @since 9
557     */
558    DATE_MODIFIED,
559    /**
560     * Title of the file, read only
561     *
562     * @syscap SystemCapability.FileManagement.UserFileManager.Core
563     * @systemapi
564     * @since 9
565     */
566    TITLE,
567    /**
568     * Duration of the audio and video file, read only
569     *
570     * @syscap SystemCapability.FileManagement.UserFileManager.Core
571     * @systemapi
572     * @since 9
573     */
574    DURATION,
575    /**
576     * Width of the image file, read only
577     *
578     * @syscap SystemCapability.FileManagement.UserFileManager.Core
579     * @systemapi
580     * @since 9
581     */
582    WIDTH,
583    /**
584     * Height of the image file, read only
585     *
586     * @syscap SystemCapability.FileManagement.UserFileManager.Core
587     * @systemapi
588     * @since 9
589     */
590    HEIGHT,
591    /**
592     * Date taken of the file, read only
593     *
594     * @syscap SystemCapability.FileManagement.UserFileManager.Core
595     * @systemapi
596     * @since 9
597     */
598    DATE_TAKEN,
599    /**
600     * Orientation of the image file, read only
601     *
602     * @syscap SystemCapability.FileManagement.UserFileManager.Core
603     * @systemapi
604     * @since 9
605     */
606    ORIENTATION,
607    /**
608     * Favorite state of the file, read only
609     *
610     * @syscap SystemCapability.FileManagement.UserFileManager.Core
611     * @systemapi
612     * @since 9
613     */
614    FAVORITE,
615    /**
616     * File position, read only
617     *
618     * @syscap SystemCapability.FileManagement.UserFileManager.Core
619     * @systemapi
620     * @since 10
621     */
622    POSITION,
623    /**
624     * Trashed date of the file, read only
625     *
626     * @syscap SystemCapability.FileManagement.UserFileManager.Core
627     * @systemapi
628     * @since 10
629     */
630    DATE_TRASHED,
631    /**
632     * Hidden state of the file, read only
633     *
634     * @syscap SystemCapability.FileManagement.UserFileManager.Core
635     * @systemapi
636     * @since 10
637     */
638    HIDDEN,
639    /**
640     * User comment info
641     *
642     * @syscap SystemCapability.FileManagement.UserFileManager.Core
643     * @systemapi
644     * @since 10
645     */
646    USER_COMMENT,
647    /**
648     * Camera shot key
649     *
650     * @syscap SystemCapability.FileManagement.UserFileManager.Core
651     * @systemapi
652     * @since 10
653     */
654    CAMERA_SHOT_KEY
655  }
656
657  /**
658   * Describes Album TYPE predicate
659   *
660   * @enum { string } AlbumKey
661   * @syscap SystemCapability.FileManagement.UserFileManager.Core
662   * @systemapi
663   * @since 9
664   */
665  enum AlbumKey {
666    /**
667     * Album uri
668     *
669     * @syscap SystemCapability.FileManagement.UserFileManager.Core
670     * @systemapi
671     * @since 9
672     */
673    URI,
674    /**
675     * File type of the Album
676     *
677     * @syscap SystemCapability.FileManagement.UserFileManager.Core
678     * @systemapi
679     * @since 9
680     */
681    FILE_TYPE,
682    /**
683     * Album name
684     *
685     * @syscap SystemCapability.FileManagement.UserFileManager.Core
686     * @systemapi
687     * @since 9
688     */
689    ALBUM_NAME,
690    /**
691     * Date of the Album creation
692     *
693     * @syscap SystemCapability.FileManagement.UserFileManager.Core
694     * @systemapi
695     * @since 9
696     */
697    DATE_ADDED,
698    /**
699     * Modify date of the Album
700     *
701     * @syscap SystemCapability.FileManagement.UserFileManager.Core
702     * @systemapi
703     * @since 9
704     */
705    DATE_MODIFIED
706  }
707
708  /**
709   * Fetch parameters
710   *
711   * @interface FetchOptions
712   * @syscap SystemCapability.FileManagement.UserFileManager.Core
713   * @systemapi
714   * @since 9
715   */
716  interface FetchOptions {
717    /**
718     * Indicates the columns to query.
719     *
720     * @type { Array<string> }
721     * @syscap SystemCapability.FileManagement.UserFileManager.Core
722     * @systemapi
723     * @since 9
724     */
725    fetchColumns: Array<string>;
726    /**
727     * Predicate to query
728     *
729     * @type { dataSharePredicates.DataSharePredicates }
730     * @syscap SystemCapability.FileManagement.UserFileManager.Core
731     * @systemapi
732     * @since 9
733     */
734    predicates: dataSharePredicates.DataSharePredicates;
735  }
736
737  /**
738   * Fetch parameters
739   *
740   * @interface AlbumFetchOptions
741   * @syscap SystemCapability.FileManagement.UserFileManager.Core
742   * @systemapi
743   * @since 9
744   */
745  interface AlbumFetchOptions {
746    /**
747     * Predicate to query
748     *
749     * @type { dataSharePredicates.DataSharePredicates }
750     * @syscap SystemCapability.FileManagement.UserFileManager.Core
751     * @systemapi
752     * @since 9
753     */
754    predicates: dataSharePredicates.DataSharePredicates;
755  }
756
757  /**
758   * Describe additional operations for creating photo
759   *
760   * @interface PhotoCreateOptions
761   * @syscap SystemCapability.FileManagement.UserFileManager.Core
762   * @systemapi
763   * @since 10
764   */
765  interface PhotoCreateOptions {
766    /**
767     * SubType of the photo
768     *
769     * @type { ?PhotoSubType }
770     * @syscap SystemCapability.FileManagement.UserFileManager.Core
771     * @systemapi
772     * @since 10
773     */
774    subType?: PhotoSubType;
775    /**
776     * Camera shot key
777     *
778     * @type { ?string }
779     * @syscap SystemCapability.FileManagement.UserFileManager.Core
780     * @systemapi
781     * @since 10
782     */
783    cameraShotKey?: string;
784  }
785
786  /**
787   * Implements file retrieval.
788   *
789   * @interface FetchResult
790   * @syscap SystemCapability.FileManagement.UserFileManager.Core
791   * @systemapi
792   * @since 9
793   */
794  interface FetchResult<T> {
795    /**
796     * Obtains the total number of files in the file retrieval result.
797     *
798     * @returns { number } Total number of files.
799     * @syscap SystemCapability.FileManagement.UserFileManager.Core
800     * @systemapi
801     * @since 9
802     */
803    getCount(): number;
804    /**
805     * Checks whether the result set points to the last row.
806     *
807     * @returns { boolean } Whether the file is the last one.
808     * You need to check whether the file is the last one before calling getNextObject,
809     * which returns the next file only when False is returned for this method.
810     * @syscap SystemCapability.FileManagement.UserFileManager.Core
811     * @systemapi
812     * @since 9
813     */
814    isAfterLast(): boolean;
815    /**
816     * Releases the FetchResult instance and invalidates it. Other methods cannot be called.
817     *
818     * @syscap SystemCapability.FileManagement.UserFileManager.Core
819     * @systemapi
820     * @since 9
821     */
822    close(): void;
823    /**
824     * Obtains the first FileAsset in the file retrieval result. This method uses a callback to return the file.
825     *
826     * @param { AsyncCallback<T> } callback - Callback used to return the file in the format of a FileAsset instance.
827     * @syscap SystemCapability.FileManagement.UserFileManager.Core
828     * @systemapi
829     * @since 9
830     */
831    getFirstObject(callback: AsyncCallback<T>): void;
832    /**
833     * Obtains the first T in the file retrieval result. This method uses a promise to return the file.
834     *
835     * @returns { Promise<T> } A Promise instance used to return the file in the format of a T instance.
836     * @syscap SystemCapability.FileManagement.UserFileManager.Core
837     * @systemapi
838     * @since 9
839     */
840    getFirstObject(): Promise<T>;
841    /**
842     * Obtains the next T in the file retrieval result.
843     * This method uses a callback to return the file.
844     * Before calling this method, you must use isAfterLast() to check whether the result set points to the last row.
845     * This method returns the next file only when False is returned for isAfterLast().
846     *
847     * @param { AsyncCallback<T> } callback - Callback used to return the file in the format of a T instance.
848     * @syscap SystemCapability.FileManagement.UserFileManager.Core
849     * @systemapi
850     * @since 9
851     */
852    getNextObject(callback: AsyncCallback<T>): void;
853    /**
854     * Obtains the next T in the file retrieval result.
855     * This method uses a promise to return the file.
856     * Before calling this method, you must use isAfterLast() to check whether the result set points to the last row.
857     * This method returns the next file only when False is returned for isAfterLast().
858     *
859     * @returns { Promise<T> } A Promise instance used to return the file in the format of a T instance.
860     * @syscap SystemCapability.FileManagement.UserFileManager.Core
861     * @systemapi
862     * @since 9
863     */
864    getNextObject(): Promise<T>;
865    /**
866     * Obtains the last T in the file retrieval result. This method uses a callback to return the file.
867     *
868     * @param { AsyncCallback<T> } callback - Callback used to return the file in the format of a T instance.
869     * @syscap SystemCapability.FileManagement.UserFileManager.Core
870     * @systemapi
871     * @since 9
872     */
873    getLastObject(callback: AsyncCallback<T>): void;
874    /**
875     * Obtains the last T in the file retrieval result. This method uses a promise to return the file.
876     *
877     * @returns { Promise<T> } A Promise instance used to return the file in the format of a T instance.
878     * @syscap SystemCapability.FileManagement.UserFileManager.Core
879     * @systemapi
880     * @since 9
881     */
882    getLastObject(): Promise<T>;
883    /**
884     * Obtains the T with the specified index in the file retrieval result.
885     * This method uses a callback to return the file.
886     *
887     * @param { number } index - Index of the file to obtain.
888     * @param { AsyncCallback<T> } callback - Callback used to return the file in the format of a T instance.
889     * @throws { BusinessError } 13900020 - if type index is not number
890     * @syscap SystemCapability.FileManagement.UserFileManager.Core
891     * @systemapi
892     * @since 9
893     */
894    getPositionObject(index: number, callback: AsyncCallback<T>): void;
895    /**
896     * Obtains the T with the specified index in the file retrieval result.
897     * This method uses a promise to return the file.
898     *
899     * @param { number } index - Index of the file to obtain.
900     * @returns { Promise<T> } A Promise instance used to return the file in the format of a T instance.
901     * @throws { BusinessError } 13900020 - if type index is not number
902     * @syscap SystemCapability.FileManagement.UserFileManager.Core
903     * @systemapi
904     * @since 9
905     */
906    getPositionObject(index: number): Promise<T>;
907    /**
908     * Obtains all T in the file retrieval result.
909     * This method uses a callback to return the result. After this method is called,
910     *
911     * @param { AsyncCallback<Array<T>> } callback - Callback used to return a T array.
912     * @syscap SystemCapability.FileManagement.UserFileManager.Core
913     * @systemapi
914     * @since 10
915     */
916    getAllObject(callback: AsyncCallback<Array<T>>): void;
917    /**
918     * Obtains all T in the file retrieval result.
919     * This method uses a promise to return the result. that store the selected media resources.
920     *
921     * @returns { Promise<Array<T>> } A Promise instance used to return a T array.
922     * @syscap SystemCapability.FileManagement.UserFileManager.Core
923     * @systemapi
924     * @since 10
925     */
926    getAllObject(): Promise<Array<T>>;
927  }
928
929  /**
930   * Album type.
931   *
932   * @enum { number } AlbumType
933   * @syscap SystemCapability.FileManagement.UserFileManager.Core
934   * @systemapi
935   * @since 10
936   */
937  enum AlbumType {
938    /**
939     * Album created by user.
940     *
941     * @syscap SystemCapability.FileManagement.UserFileManager.Core
942     * @systemapi
943     * @since 10
944     */
945    USER = 0,
946    /**
947     * Album created by system, which metadata cannot be modified by user.
948     *
949     * @syscap SystemCapability.FileManagement.UserFileManager.Core
950     * @systemapi
951     * @since 10
952     */
953    SYSTEM = 1024
954  }
955
956  /**
957   * Album subtype
958   *
959   * @enum { number } AlbumSubType
960   * @syscap SystemCapability.FileManagement.UserFileManager.Core
961   * @systemapi
962   * @since 10
963   */
964  enum AlbumSubType {
965    /**
966     * Generic user-created albums.
967     *
968     * @syscap SystemCapability.FileManagement.UserFileManager.Core
969     * @systemapi
970     * @since 10
971     */
972    USER_GENERIC = 1,
973    /**
974     * Favorite album, which assets are marked as favorite.
975     *
976     * @syscap SystemCapability.FileManagement.UserFileManager.Core
977     * @systemapi
978     * @since 10
979     */
980    FAVORITE = 1025,
981    /**
982     * Video album, which contains all video assets.
983     *
984     * @syscap SystemCapability.FileManagement.UserFileManager.Core
985     * @systemapi
986     * @since 10
987     */
988    VIDEO,
989    /**
990     * Hidden album, which assets are marked as hidden.
991     *
992     * @syscap SystemCapability.FileManagement.UserFileManager.Core
993     * @systemapi
994     * @since 10
995     */
996    HIDDEN,
997    /**
998     * Trash album, which assets are deleted.
999     *
1000     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1001     * @systemapi
1002     * @since 10
1003     */
1004    TRASH,
1005    /**
1006     * Screenshot album
1007     *
1008     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1009     * @systemapi
1010     * @since 10
1011     */
1012    SCREENSHOT,
1013    /**
1014     * Camera album
1015     *
1016     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1017     * @systemapi
1018     * @since 10
1019     */
1020    CAMERA,
1021    /**
1022     * Any album
1023     *
1024     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1025     * @systemapi
1026     * @since 10
1027     */
1028    ANY = 2147483647
1029  }
1030
1031  /**
1032   * Defines the AbsAlbum.
1033   *
1034   * @interface AbsAlbum
1035   * @syscap SystemCapability.FileManagement.UserFileManager.Core
1036   * @systemapi
1037   * @since 9
1038   */
1039  interface AbsAlbum {
1040    /**
1041     * Album type
1042     *
1043     * @type { AlbumType }
1044     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1045     * @systemapi
1046     * @since 10
1047     */
1048    readonly albumType: AlbumType;
1049    /**
1050     * Album subtype
1051     *
1052     * @type { AlbumSubType }
1053     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1054     * @systemapi
1055     * @since 10
1056     */
1057    readonly albumSubType: AlbumSubType;
1058    /**
1059     * Album name.
1060     *
1061     * @type { string }
1062     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1063     * @systemapi
1064     * @since 9
1065     */
1066    albumName: string;
1067    /**
1068     * Album uri.
1069     *
1070     * @type { string }
1071     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1072     * @systemapi
1073     * @since 9
1074     */
1075    readonly albumUri: string;
1076    /**
1077     * Date (timestamp) when the album was last modified.
1078     *
1079     * @type { number }
1080     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1081     * @systemapi
1082     * @since 9
1083     */
1084    readonly dateModified: number;
1085    /**
1086     * File count for the album
1087     *
1088     * @type { number }
1089     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1090     * @systemapi
1091     * @since 9
1092     */
1093    readonly count: number;
1094    /**
1095     * CoverUri for the album
1096     *
1097     * @type { string }
1098     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1099     * @systemapi
1100     * @since 9
1101     */
1102    coverUri: string;
1103    /**
1104     * Obtains files in an album. This method uses an asynchronous callback to return the files.
1105     *
1106     * @permission ohos.permission.READ_IMAGEVIDEO
1107     * @param { FetchOptions } options - Retrieval options.
1108     * @param { AsyncCallback<FetchResult<FileAsset>> } callback - Callback used to return the files in the format of a FetchResult instance.
1109     * @throws { BusinessError } 13900020 - if type options is not FetchOptions
1110     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1111     * @systemapi
1112     * @since 9
1113     */
1114    getPhotoAssets(options: FetchOptions, callback: AsyncCallback<FetchResult<FileAsset>>): void;
1115    /**
1116     * Obtains files in an album. This method uses a promise to return the files.
1117     *
1118     * @permission ohos.permission.READ_IMAGEVIDEO
1119     * @param { FetchOptions } options - Retrieval options.
1120     * @returns { Promise<FetchResult<FileAsset>> } A Promise instance used to return the files in the format of a FetchResult instance.
1121     * @throws { BusinessError } 13900020 - if type options is not FetchOptions
1122     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1123     * @systemapi
1124     * @since 9
1125     */
1126    getPhotoAssets(options: FetchOptions): Promise<FetchResult<FileAsset>>;
1127  }
1128
1129  /**
1130   * Defines the album.
1131   *
1132   * @interface Album
1133   * @syscap SystemCapability.FileManagement.UserFileManager.Core
1134   * @systemapi
1135   * @since 9
1136   */
1137  interface Album extends AbsAlbum {
1138    /**
1139     * Modify the meta data for the album
1140     *
1141     * @permission ohos.permission.WRITE_IMAGEVIDEO
1142     * @param { AsyncCallback<void> } callback - No value will be returned.
1143     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1144     * @systemapi
1145     * @since 9
1146     */
1147    commitModify(callback: AsyncCallback<void>): void;
1148    /**
1149     * Modify the meta data for the album
1150     *
1151     * @permission ohos.permission.WRITE_IMAGEVIDEO
1152     * @returns { Promise<void> } Return promise
1153     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1154     * @systemapi
1155     * @since 9
1156     */
1157    commitModify(): Promise<void>;
1158    /**
1159     * Add PhotoAssets to the album.
1160     *
1161     * @permission ohos.permission.WRITE_IMAGEVIDEO
1162     * @param { Array<FileAsset> } assets - Assets to add
1163     * @param { AsyncCallback<void> } callback - Returns void
1164     * @throws { BusinessError } 13900020 - if PhotoAssets is invalid
1165     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1166     * @systemapi
1167     * @since 10
1168     */
1169    addPhotoAssets(assets: Array<FileAsset>, callback: AsyncCallback<void>): void;
1170    /**
1171     * Add PhotoAssets to the album.
1172     *
1173     * @permission ohos.permission.WRITE_IMAGEVIDEO
1174     * @param { Array<FileAsset> } assets - Assets to add
1175     * @returns { Promise<void> } Returns the promise
1176     * @throws { BusinessError } 13900020 - if PhotoAssets is invalid
1177     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1178     * @systemapi
1179     * @since 10
1180     */
1181    addPhotoAssets(assets: Array<FileAsset>): Promise<void>;
1182    /**
1183     * Remove PhotoAssets from the album.
1184     *
1185     * @permission ohos.permission.WRITE_IMAGEVIDEO
1186     * @param { Array<FileAsset> } assets - Assets to remove
1187     * @param { AsyncCallback<void> } callback - Returns void
1188     * @throws { BusinessError } 13900020 - if PhotoAssets is invalid
1189     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1190     * @systemapi
1191     * @since 10
1192     */
1193    removePhotoAssets(assets: Array<FileAsset>, callback: AsyncCallback<void>): void;
1194    /**
1195     * Remove PhotoAssets from the album.
1196     *
1197     * @permission ohos.permission.WRITE_IMAGEVIDEO
1198     * @param { Array<FileAsset> } assets - Assets to remove
1199     * @returns { Promise<void> } Returns the promise
1200     * @throws { BusinessError } 13900020 - if PhotoAssets is invalid
1201     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1202     * @systemapi
1203     * @since 10
1204     */
1205    removePhotoAssets(assets: Array<FileAsset>): Promise<void>;
1206    /**
1207     * Recover PhotoAssets from the trash album.
1208     *
1209     * @permission ohos.permission.WRITE_IMAGEVIDEO
1210     * @param { Array<FileAsset> } assets - Assets to recover
1211     * @param { AsyncCallback<void> } callback - Returns void
1212     * @throws { BusinessError } 13900020 - if PhotoAssets is invalid
1213     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1214     * @systemapi
1215     * @since 10
1216     */
1217    recoverPhotoAssets(assets: Array<FileAsset>, callback: AsyncCallback<void>): void;
1218    /**
1219     * Recover PhotoAssets from the trash album.
1220     *
1221     * @permission ohos.permission.WRITE_IMAGEVIDEO
1222     * @param { Array<FileAsset> } assets - Assets to recover
1223     * @returns { Promise<void> } Returns the promise
1224     * @throws { BusinessError } 13900020 - if PhotoAssets is invalid
1225     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1226     * @systemapi
1227     * @since 10
1228     */
1229    recoverPhotoAssets(assets: Array<FileAsset>): Promise<void>;
1230    /**
1231     * Delete PhotoAssets permanently from the trash album.
1232     *
1233     * @permission ohos.permission.WRITE_IMAGEVIDEO
1234     * @param { Array<FileAsset> } assets - Assets to delete
1235     * @param { AsyncCallback<void> } callback - Returns void
1236     * @throws { BusinessError } 13900020 - if PhotoAssets is invalid
1237     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1238     * @systemapi
1239     * @since 10
1240     */
1241    deletePhotoAssets(assets: Array<FileAsset>, callback: AsyncCallback<void>): void;
1242    /**
1243     * Delete PhotoAssets permanently from the trash album.
1244     *
1245     * @permission ohos.permission.WRITE_IMAGEVIDEO
1246     * @param { Array<FileAsset> } assets - Assets to delete
1247     * @returns { Promise<void> } Returns the promise
1248     * @throws { BusinessError } 13900020 - if PhotoAssets is invalid
1249     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1250     * @systemapi
1251     * @since 10
1252     */
1253    deletePhotoAssets(assets: Array<FileAsset>): Promise<void>;
1254  }
1255
1256  /**
1257   * Defines the UserFileManager class and provides functions to access the data in user file storage.
1258   *
1259   * @interface UserFileManager
1260   * @syscap SystemCapability.FileManagement.UserFileManager.Core
1261   * @systemapi
1262   * @since 9
1263   */
1264  interface UserFileManager {
1265    /**
1266     * Query photo, video assets
1267     *
1268     * @permission ohos.permission.READ_IMAGEVIDEO
1269     * @param { FetchOptions } options - retrieval options.
1270     * @param { AsyncCallback<FetchResult<FileAsset>> } callback - Callback return the FetchResult.
1271     * @throws { BusinessError } 13900020 - if type options is not FetchOptions
1272     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1273     * @systemapi
1274     * @since 9
1275     */
1276    getPhotoAssets(options: FetchOptions, callback: AsyncCallback<FetchResult<FileAsset>>): void;
1277    /**
1278     * Query photo, video assets
1279     *
1280     * @permission ohos.permission.READ_IMAGEVIDEO
1281     * @param { FetchOptions } options - Retrieval options.
1282     * @returns { Promise<FetchResult<FileAsset>> } A promise instance used to return the files in the format of a FetchResult instance
1283     * @throws { BusinessError } 13900020 - if type options is not FetchOptions
1284     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1285     * @systemapi
1286     * @since 9
1287     */
1288    getPhotoAssets(options: FetchOptions): Promise<FetchResult<FileAsset>>;
1289    /**
1290     * Create Photo Asset
1291     *
1292     * @permission ohos.permission.WRITE_IMAGEVIDEO
1293     * @param { string } displayName - File name
1294     * @param { string } albumUri - Asset will put into the album.
1295     * @param { AsyncCallback<FileAsset> } callback - Callback used to return the FileAsset
1296     * @throws { BusinessError } 13900020 - if type displayName or albumUri is not string
1297     * @throws { BusinessError } 14000001 - if type displayName invalid
1298     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1299     * @systemapi
1300     * @since 9
1301     */
1302    createPhotoAsset(displayName: string, albumUri: string, callback: AsyncCallback<FileAsset>): void;
1303    /**
1304     * Create Photo Asset
1305     *
1306     * @permission ohos.permission.WRITE_IMAGEVIDEO
1307     * @param { string } displayName - File name
1308     * @param { AsyncCallback<FileAsset> } callback - Callback used to return the FileAsset
1309     * @throws { BusinessError } 13900020 - if type displayName is not string
1310     * @throws { BusinessError } 14000001 - if type displayName invalid
1311     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1312     * @systemapi
1313     * @since 9
1314     */
1315    createPhotoAsset(displayName: string, callback: AsyncCallback<FileAsset>): void;
1316    /**
1317     * Create Photo Asset
1318     *
1319     * @permission ohos.permission.WRITE_IMAGEVIDEO
1320     * @param { string } displayName - File name
1321     * @param { string } albumUri - Album uri is optional, PhotoAssets will put into the default album without albumUri
1322     * @returns { Promise<FileAsset> } A Promise instance used to return the FileAsset
1323     * @throws { BusinessError } 13900020 - if type displayName or albumUri is not string
1324     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1325     * @systemapi
1326     * @since 9
1327     */
1328    createPhotoAsset(displayName: string, albumUri?: string): Promise<FileAsset>;
1329    /**
1330     * Create Photo Asset
1331     *
1332     * @permission ohos.permission.WRITE_IMAGEVIDEO
1333     * @param { string } displayName - File name
1334     * @param { PhotoCreateOptions } createOption - Create operation
1335     * @returns { Promise<FileAsset> } A Promise instance used to return the FileAsset
1336     * @throws { BusinessError } 13900020 - if type displayName is not string
1337     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1338     * @systemapi
1339     * @since 9
1340     */
1341    createPhotoAsset(displayName: string, createOption: PhotoCreateOptions): Promise<FileAsset>;
1342    /**
1343     * Create Photo Asset
1344     *
1345     * @permission ohos.permission.WRITE_IMAGEVIDEO
1346     * @param { string } displayName - File name
1347     * @param { PhotoCreateOptions } createOption - Photo create operation
1348     * @param { AsyncCallback<FileAsset> } callback - Callback used to return the FileAsset
1349     * @throws { BusinessError } 13900020 - if type displayName is not string
1350     * @throws { BusinessError } 14000001 - if type displayName invalid
1351     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1352     * @systemapi
1353     * @since 9
1354     */
1355    createPhotoAsset(displayName: string, createOption: PhotoCreateOptions, callback: AsyncCallback<FileAsset>): void;
1356    /**
1357     * Create Audio Asset
1358     *
1359     * @permission ohos.permission.WRITE_AUDIO
1360     * @param { string } displayName - File name
1361     * @param { AsyncCallback<FileAsset> } callback - Callback used to return the FileAsset
1362     * @throws { BusinessError } 13900020 - if type displayName is not string
1363     * @throws { BusinessError } 14000001 - if type displayName invalid
1364     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1365     * @systemapi
1366     * @since 10
1367     */
1368    createAudioAsset(displayName: string, callback: AsyncCallback<FileAsset>): void;
1369    /**
1370     * Create Audio Asset
1371     *
1372     * @permission ohos.permission.WRITE_AUDIO
1373     * @param { string } displayName - File name
1374     * @returns { Promise<FileAsset> } A Promise instance used to return the FileAsset
1375     * @throws { BusinessError } 13900020 - if type displayName is not string
1376     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1377     * @systemapi
1378     * @since 10
1379     */
1380    createAudioAsset(displayName: string): Promise<FileAsset>;
1381    /**
1382     * Obtains albums based on the retrieval options. This method uses an asynchronous callback to return.
1383     *
1384     * @permission ohos.permission.READ_IMAGEVIDEO
1385     * @param { AlbumFetchOptions } options - Retrieval options.
1386     * @param { AsyncCallback<FetchResult<Album>> } callback - Callback used to return an album array.
1387     * @throws { BusinessError } 13900020 - if type options is not AlbumFetchOptions
1388     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1389     * @systemapi
1390     * @since 9
1391     */
1392    getPhotoAlbums(options: AlbumFetchOptions, callback: AsyncCallback<FetchResult<Album>>): void;
1393    /**
1394     * Obtains albums based on the retrieval options. This method uses a promise to return the albums.
1395     *
1396     * @permission ohos.permission.READ_IMAGEVIDEO
1397     * @param { AlbumFetchOptions } options - Retrieval options.
1398     * @returns { Promise<FetchResult<Album>> } A Promise instance used to return an album array.
1399     * @throws { BusinessError } 13900020 - if type options is not AlbumFetchOptions
1400     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1401     * @systemapi
1402     * @since 9
1403     */
1404    getPhotoAlbums(options: AlbumFetchOptions): Promise<FetchResult<Album>>;
1405    /**
1406     * Create a generic user album.
1407     *
1408     * @permission ohos.permission.WRITE_IMAGEVIDEO
1409     * @param { string } name - Album name to be created.
1410     * @param { AsyncCallback<Album> } callback - Returns the instance of newly created Album
1411     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1412     * @systemapi
1413     * @since 10
1414     */
1415    createAlbum(name: string, callback: AsyncCallback<Album>): void;
1416    /**
1417     * Create a generic user album.
1418     *
1419     * @permission ohos.permission.WRITE_IMAGEVIDEO
1420     * @param { string } name - Album name to be created.
1421     * @returns { Promise<Album> } Returns the instance of newly created Album
1422     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1423     * @systemapi
1424     * @since 10
1425     */
1426    createAlbum(name: string): Promise<Album>;
1427    /**
1428     * Delete generic user-created albums.
1429     *
1430     * @permission ohos.permission.WRITE_IMAGEVIDEO
1431     * @param { Array<Album> } albums - Specify which album to delete
1432     * @param { AsyncCallback<void> } callback - Returns void
1433     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1434     * @systemapi
1435     * @since 10
1436     */
1437    deleteAlbums(albums: Array<Album>, callback: AsyncCallback<void>): void;
1438    /**
1439     * Delete generic user-created albums.
1440     *
1441     * @permission ohos.permission.WRITE_IMAGEVIDEO
1442     * @param { Array<Album> } albums - Specify which album to delete
1443     * @returns { Promise<void> } Returns the promise
1444     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1445     * @systemapi
1446     * @since 10
1447     */
1448    deleteAlbums(albums: Array<Album>): Promise<void>;
1449    /**
1450     * Obtains albums based on the retrieval options and album types.
1451     *
1452     * @permission ohos.permission.READ_IMAGEVIDEO
1453     * @param { AlbumType } type - Album type.
1454     * @param { AlbumSubType } subType - Album subtype.
1455     * @param { FetchOptions } options - options to fetch albums
1456     * @param { AsyncCallback<FetchResult<Album>> } callback - Returns the fetch result of the albums
1457     * @throws { BusinessError } 13900020 - if type options is not FetchOption
1458     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1459     * @systemapi
1460     * @since 10
1461     */
1462    getAlbums(
1463      type: AlbumType,
1464      subType: AlbumSubType,
1465      options: FetchOptions,
1466      callback: AsyncCallback<FetchResult<Album>>
1467    ): void;
1468    /**
1469     * Obtains albums based on the album types.
1470     *
1471     * @permission ohos.permission.READ_IMAGEVIDEO
1472     * @param { AlbumType } type - Album type.
1473     * @param { AlbumSubType } subType - Album subtype.
1474     * @param { AsyncCallback<FetchResult<Album>> } callback - Returns the fetch result of the albums
1475     * @throws { BusinessError } 13900020 - if type options is not FetchOption
1476     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1477     * @systemapi
1478     * @since 10
1479     */
1480    getAlbums(type: AlbumType, subType: AlbumSubType, callback: AsyncCallback<FetchResult<Album>>): void;
1481    /**
1482     * Obtains albums based on the retrieval options and album types.
1483     *
1484     * @permission ohos.permission.READ_IMAGEVIDEO
1485     * @param { AlbumType } type - Album type.
1486     * @param { AlbumSubType } subType - Album subtype.
1487     * @param { FetchOptions } [options] -options to fetch albums
1488     * @returns { Promise<FetchResult<Album>> } - Returns the fetch result of the albums
1489     * @throws { BusinessError } 13900020 - if type options is not FetchOption
1490     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1491     * @systemapi
1492     * @since 10
1493     */
1494    getAlbums(type: AlbumType, subType: AlbumSubType, options?: FetchOptions): Promise<FetchResult<Album>>;
1495    /**
1496     * Obtains system private albums based on the private album type. This method uses an asynchronous callback to return.
1497     *
1498     * @permission ohos.permission.READ_IMAGEVIDEO
1499     * @param { PrivateAlbumType } type - Private album type
1500     * @param { AsyncCallback<FetchResult<PrivateAlbum>> } callback - Used to return a private album FetchResult.
1501     * @throws { BusinessError } 13900020 - if type type is not PrivateAlbumType
1502     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1503     * @systemapi
1504     * @since 9
1505     */
1506    getPrivateAlbum(type: PrivateAlbumType, callback: AsyncCallback<FetchResult<PrivateAlbum>>): void;
1507    /**
1508     * Obtains system private albums based on the private album type. This method uses a promise to return.
1509     *
1510     * @permission ohos.permission.READ_IMAGEVIDEO
1511     * @param { PrivateAlbumType } type - Private album type
1512     * @returns { Promise<FetchResult<PrivateAlbum>> } A Promise instance used to return a private album FetchResult.
1513     * @throws { BusinessError } 13900020 - if type type is not PrivateAlbumType
1514     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1515     * @systemapi
1516     * @since 9
1517     */
1518    getPrivateAlbum(type: PrivateAlbumType): Promise<FetchResult<PrivateAlbum>>;
1519    /**
1520     * Query audio assets
1521     *
1522     * @permission ohos.permission.READ_AUDIO
1523     * @param { FetchOptions } options - Retrieval options.
1524     * @param { AsyncCallback<FetchResult<FileAsset>> } callback - Callback return the FetchResult.
1525     * @throws { BusinessError } 13900020 - if type options is not FetchOptions
1526     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1527     * @systemapi
1528     * @since 9
1529     */
1530    getAudioAssets(options: FetchOptions, callback: AsyncCallback<FetchResult<FileAsset>>): void;
1531    /**
1532     * Query audio assets
1533     *
1534     * @permission ohos.permission.READ_AUDIO
1535     * @param { FetchOptions } options - Retrieval options.
1536     * @returns { Promise<FetchResult<FileAsset>> } A promise instance used to return the files in the format of a FetchResult instance
1537     * @throws { BusinessError } 13900020 - if type options is not FetchOptions
1538     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1539     * @systemapi
1540     * @since 9
1541     */
1542    getAudioAssets(options: FetchOptions): Promise<FetchResult<FileAsset>>;
1543    /**
1544     * Delete Asset
1545     *
1546     * @permission ohos.permission.READ_IMAGEVIDEO and ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO and ohos.permission.WRITE_AUDIO
1547     * @param { string } uri - Uri of FileAsset
1548     * @param { AsyncCallback<void> } callback - No value returned
1549     * @throws { BusinessError } 13900020 - if type uri is not string
1550     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1551     * @systemapi
1552     * @since 9
1553     */
1554    delete(uri: string, callback: AsyncCallback<void>): void;
1555    /**
1556     * Delete Asset
1557     *
1558     * @permission ohos.permission.READ_IMAGEVIDEO and ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO and ohos.permission.WRITE_AUDIO
1559     * @param { string } uri - Uri of FileAsset
1560     * @returns { Promise<void> } A Promise instance, no value returned
1561     * @throws { BusinessError } 13900020 - if type uri is not string
1562     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1563     * @systemapi
1564     * @since 9
1565     */
1566    delete(uri: string): Promise<void>;
1567    /**
1568     * Get the index of the asset in the album
1569     *
1570     * @permission ohos.permission.READ_IMAGEVIDEO
1571     * @param { string } photoUri - The photo asset uri.
1572     * @param { string } albumUri - The album uri.
1573     * @param { FetchOptions } options - fetch options
1574     * @param { AsyncCallback<number> } callback - Returns the index of the asset in the album
1575     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1576     * <br>2. Incorrect parameter types; 3. Parameter verification failed.
1577     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1578     * @systemapi
1579     * @since 10
1580     */
1581    getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions, callback: AsyncCallback<number>): void;
1582    /**
1583     * Get the index of the asset in the album
1584     *
1585     * @permission ohos.permission.READ_IMAGEVIDEO
1586     * @param { string } photoUri - The photo asset uri.
1587     * @param { string } albumUri - The album uri.
1588     * @param { FetchOptions } options - fetch options
1589     * @returns { Promise<number> } - Returns the index of the asset in the album
1590     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1591     * <br>2. Incorrect parameter types; 3. Parameter verification failed.
1592     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1593     * @systemapi
1594     * @since 10
1595     */
1596    getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions): Promise<number>;
1597    /**
1598     * Turn on monitor the data changes
1599     *
1600     * @param { ChangeEvent } type - One of 'deviceChange','albumChange','imageChange','audioChange','videoChange','remoteFileChange'
1601     * @param { Callback<void> } callback - No value returned
1602     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1603     * @systemapi
1604     * @since 9
1605     */
1606    on(type: ChangeEvent, callback: Callback<void>): void;
1607    /**
1608     * Turn off monitor the data changes
1609     *
1610     * @param { ChangeEvent } type - One of 'deviceChange','albumChange','imageChange','audioChange','videoChange','remoteFileChange'
1611     * @param { Callback<void> } callback - No value returned
1612     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1613     * @systemapi
1614     * @since 9
1615     */
1616    off(type: ChangeEvent, callback?: Callback<void>): void;
1617    /**
1618     * Turn on monitor for the specified uri.
1619     *
1620     * @param { string } uri - FileAsset's uri, album's uri or DefaultChangeUri
1621     * @param { boolean } forSubUri - Monitor the sub uri.
1622     * @param { Callback<ChangeData> } callback - callback function, return the ChangeData to be monitored
1623     * @throws { BusinessError } 13900020 - if parameter is invalid
1624     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1625     * @systemapi
1626     * @since 10
1627     */
1628    on(uri: string, forSubUri: boolean, callback: Callback<ChangeData>): void;
1629    /**
1630     * Turn off monitor for the specified uri.
1631     *
1632     * @param { string } uri - FileAsset's uri, Album's uri or DefaultChangeUri value
1633     * @param { Callback<ChangeData> } [callback] - Remove specified callback from monitoring to a specified uri
1634     * @throws { BusinessError } 13900020 - if parameter is invalid
1635     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1636     * @systemapi
1637     * @since 10
1638     */
1639    off(uri: string, callback?: Callback<ChangeData>): void;
1640    /**
1641     * Get Active Peer device information
1642     *
1643     * @param { AsyncCallback<Array<PeerInfo>> } callback - Callback return the list of the active peer devices' information
1644     * @syscap SystemCapability.FileManagement.UserFileManager.DistributedCore
1645     * @systemapi
1646     * @since 9
1647     */
1648    getActivePeers(callback: AsyncCallback<Array<PeerInfo>>): void;
1649    /**
1650     * Get Active Peer device information
1651     *
1652     * @returns { Promise<Array<PeerInfo>> } Promise used to return the list of the active peer devices' information
1653     * @syscap SystemCapability.FileManagement.UserFileManager.DistributedCore
1654     * @systemapi
1655     * @since 9
1656     */
1657    getActivePeers(): Promise<Array<PeerInfo>>;
1658    /**
1659     * Get all the peer devices' information
1660     *
1661     * @param { AsyncCallback<Array<PeerInfo>> } callback - Callback return the list of the all the peer devices' information
1662     * @syscap SystemCapability.FileManagement.UserFileManager.DistributedCore
1663     * @systemapi
1664     * @since 9
1665     */
1666    getAllPeers(callback: AsyncCallback<Array<PeerInfo>>): void;
1667    /**
1668     * Get all the peer devices' information
1669     *
1670     * @returns { Promise<Array<PeerInfo>> } Promise used to return the list of the all the peer devices' information
1671     * @syscap SystemCapability.FileManagement.UserFileManager.DistributedCore
1672     * @systemapi
1673     * @since 9
1674     */
1675    getAllPeers(): Promise<Array<PeerInfo>>;
1676    /**
1677     * Release UserFileManager instance
1678     *
1679     * @param { AsyncCallback<void> } callback - No value returned
1680     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1681     * @systemapi
1682     * @since 9
1683     */
1684    release(callback: AsyncCallback<void>): void;
1685    /**
1686     * Release UserFileManager instance
1687     *
1688     * @returns { Promise<void> } Return promise
1689     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1690     * @systemapi
1691     * @since 9
1692     */
1693    release(): Promise<void>;
1694  }
1695
1696  /**
1697   * NotifyType subtype
1698   *
1699   * @enum { number } NotifyType subtype
1700   * @syscap SystemCapability.FileManagement.UserFileManager.Core
1701   * @systemapi
1702   * @since 10
1703   */
1704  enum NotifyType {
1705    /**
1706     * Type for add notification of the FileAsset or Album
1707     *
1708     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1709     * @systemapi
1710     * @since 10
1711     */
1712    NOTIFY_ADD,
1713    /**
1714     * Type for update notification of the FileAsset or Album
1715     *
1716     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1717     * @systemapi
1718     * @since 10
1719     */
1720    NOTIFY_UPDATE,
1721    /**
1722     * Type for remove notification of the FileAsset or Album
1723     *
1724     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1725     * @systemapi
1726     * @since 10
1727     */
1728    NOTIFY_REMOVE,
1729    /**
1730     * Type for notification of the FileAsset added at an Album
1731     *
1732     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1733     * @systemapi
1734     * @since 10
1735     */
1736    NOTIFY_ALBUM_ADD_ASSET,
1737    /**
1738     * Type for notification of the FileAsset removed at an Album
1739     *
1740     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1741     * @systemapi
1742     * @since 10
1743     */
1744    NOTIFY_ALBUM_REMOVE_ASSET
1745  }
1746
1747  /**
1748   * DefaultChangeUri subtype
1749   *
1750   * @enum { string } DefaultChangeUri subtype
1751   * @syscap SystemCapability.FileManagement.UserFileManager.Core
1752   * @systemapi
1753   * @since 10
1754   */
1755  enum DefaultChangeUri {
1756    /**
1757     * Uri for default PhotoAsset, use with forDescendant{true}, will recieve all PhotoAsset's change notifications
1758     *
1759     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1760     * @systemapi
1761     * @since 10
1762     */
1763    DEFAULT_PHOTO_URI,
1764    /**
1765     * Uri for default Album, use with forDescendant{true}, will recieve all Album's change notifications
1766     *
1767     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1768     * @systemapi
1769     * @since 10
1770     */
1771    DEFAULT_ALBUM_URI,
1772    /**
1773     * Uri for default AudioAsset, use with forDescendant{true}, will recieve all AudioAsset's change notifications
1774     *
1775     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1776     * @systemapi
1777     * @since 10
1778     */
1779    DEFAULT_AUDIO_URI
1780  }
1781
1782  /**
1783   * the value of the monitor callback function
1784   *
1785   * @interface ChangeData
1786   * @syscap SystemCapability.FileManagement.UserFileManager.Core
1787   * @systemapi
1788   * @since 10
1789   */
1790  interface ChangeData {
1791    /**
1792     * the NotifyType of ChangeData
1793     *
1794     * @type { NotifyType }
1795     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1796     * @systemapi
1797     * @since 10
1798     */
1799    type: NotifyType;
1800    /**
1801     * all uris of the same NotifyType, could be FileAssets' or Albums'
1802     *
1803     * @type { Array<string> }
1804     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1805     * @systemapi
1806     * @since 10
1807     */
1808    uris: Array<string>;
1809    /**
1810     * change details of the Album's FileAssets when uris is the Album's uri type
1811     *
1812     * @type { Array<string> }
1813     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1814     * @systemapi
1815     * @since 10
1816     */
1817    subUris: Array<string>;
1818  }
1819
1820  /**
1821   * Peer devices' information
1822   *
1823   * @interface PeerInfo
1824   * @syscap SystemCapability.FileManagement.UserFileManager.DistributedCore
1825   * @systemapi
1826   * @since 9
1827   */
1828  interface PeerInfo {
1829    /**
1830     * Peer device name
1831     *
1832     * @type { string }
1833     * @syscap SystemCapability.FileManagement.UserFileManager.DistributedCore
1834     * @systemapi
1835     * @since 9
1836     */
1837    readonly deviceName: string;
1838    /**
1839     * Peer device network id
1840     *
1841     * @type { string }
1842     * @syscap SystemCapability.FileManagement.UserFileManager.DistributedCore
1843     * @systemapi
1844     * @since 9
1845     */
1846    readonly networkId: string;
1847    /**
1848     * Peer device online status
1849     *
1850     * @type { boolean }
1851     * @syscap SystemCapability.FileManagement.UserFileManager.DistributedCore
1852     * @systemapi
1853     * @since 9
1854     */
1855    readonly isOnline: boolean;
1856  }
1857
1858  /**
1859   * Private album type
1860   *
1861   * @enum { string } PrivateAlbumType
1862   * @syscap SystemCapability.FileManagement.UserFileManager.Core
1863   * @systemapi
1864   * @since 9
1865   */
1866  enum PrivateAlbumType {
1867    /**
1868     * System Private Album: Favorite album
1869     *
1870     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1871     * @systemapi
1872     * @since 9
1873     */
1874    TYPE_FAVORITE,
1875    /**
1876     * System Private Album: Trash album
1877     *
1878     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1879     * @systemapi
1880     * @since 9
1881     */
1882    TYPE_TRASH
1883  }
1884
1885  /**
1886   * Defines the private album
1887   *
1888   * @interface PrivateAlbum
1889   * @syscap SystemCapability.FileManagement.UserFileManager.Core
1890   * @systemapi
1891   * @since 9
1892   */
1893  interface PrivateAlbum extends AbsAlbum {
1894    /**
1895     * Delete asset permanently from Trash bin, only support the Trash album
1896     *
1897     * @permission ohos.permission.READ_IMAGEVIDEO and ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO and ohos.permission.WRITE_AUDIO
1898     * @param { string } uri - uri of asset
1899     * @param { AsyncCallback<void> } callback - No value returned
1900     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1901     * @systemapi
1902     * @since 9
1903     */
1904    delete(uri: string, callback: AsyncCallback<void>): void;
1905    /**
1906     * Delete asset permanently from Trash bin, only support the Trash album
1907     *
1908     * @permission ohos.permission.READ_IMAGEVIDEO and ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO and ohos.permission.WRITE_AUDIO
1909     * @param { string } uri - Uri of asset
1910     * @returns { Promise<void> } A Promise instance, no value returned
1911     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1912     * @systemapi
1913     * @since 9
1914     */
1915    delete(uri: string): Promise<void>;
1916    /**
1917     * Recover asset from Trash bin, only support the Trash album
1918     *
1919     * @permission ohos.permission.READ_IMAGEVIDEO and ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO and ohos.permission.WRITE_AUDIO
1920     * @param { string } uri - Uri of asset
1921     * @param { AsyncCallback<void> } callback - No value returned
1922     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1923     * @systemapi
1924     * @since 9
1925     */
1926    recover(uri: string, callback: AsyncCallback<void>): void;
1927    /**
1928     * Recover asset from Trash bin, only support the Trash album
1929     *
1930     * @permission ohos.permission.READ_IMAGEVIDEO and ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO and ohos.permission.WRITE_AUDIO
1931     * @param { string } uri - Uri of asset
1932     * @returns { Promise<void> } A Promise instance, no value returned
1933     * @syscap SystemCapability.FileManagement.UserFileManager.Core
1934     * @systemapi
1935     * @since 9
1936     */
1937    recover(uri: string): Promise<void>;
1938  }
1939}
1940
1941export default userFileManager;
1942