1 Star 0 Fork 4K

Feng Lin/interface_sdk-js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
@ohos.filemanagement.userFileManager.d.ts 62.57 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941
/*
* Copyright (C) 2022-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* @kit CoreFileKit
*/
import type { AsyncCallback, Callback } from './@ohos.base';
import type Context from './application/Context';
import image from './@ohos.multimedia.image';
import dataSharePredicates from './@ohos.data.dataSharePredicates';
/**
* @namespace userFileManager
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
declare namespace userFileManager {
/**
* Returns an instance of UserFileManager
*
* @param { Context } context - Hap context information
* @returns { UserFileManager } Instance of UserFileManager
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @StageModelOnly
* @since 9
*/
function getUserFileMgr(context: Context): UserFileManager;
/**
* Enumeration types for different kinds of Files
*
* @enum { number } FileType
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
enum FileType {
/**
* Image file type
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
IMAGE = 1,
/**
* Video file type
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
VIDEO,
/**
* Audio file type
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
AUDIO
}
/**
* Enumeration types for different types of FileAsset
*
* @enum { number } PhotoSubType
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
enum PhotoSubType {
/**
* Default Photo Type
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
DEFAULT,
/**
* Screenshot Photo Type
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
SCREENSHOT,
/**
* Camera Photo Type
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
CAMERA
}
/**
* File position
*
* @enum { number } File position, which indicates the file is on local device or cloud
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
enum PositionType {
/**
* File exists only on local device
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
LOCAL = 1,
/**
* File exists only on cloud
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
CLOUD,
/**
* File exists on both local and cloud
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
BOTH
}
/**
* Indicates the type of file asset member.
*
* @typedef { number | string | boolean } MemberType
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
type MemberType = number | string | boolean;
/**
* Indicates the type of notify event.
*
* @typedef { 'deviceChange' | 'albumChange' | 'imageChange' | 'audioChange' | 'videoChange' | 'remoteFileChange' } ChangeEvent
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
type ChangeEvent =
'deviceChange'
| 'albumChange'
| 'imageChange'
| 'audioChange'
| 'videoChange'
| 'remoteFileChange';
/**
* Provides methods to encapsulate file attributes.
*
* @interface FileAsset
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
interface FileAsset {
/**
* URI of the file.
*
* @type { string }
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
readonly uri: string;
/**
* File type, for example, IMAGE, VIDEO, AUDIO
*
* @type { FileType }
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
readonly fileType: FileType;
/**
* Display name (with a file name extension) of the file.
*
* @type { string }
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
displayName: string;
/**
* Return the fileAsset member parameter.
*
* @param { string } member - The name of the parameter. for example : get(ImageVideoKey.URI)
* @returns { MemberType }
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
get(member: string): MemberType;
/**
* Set the fileAsset member parameter.
*
* @param { string } member - The name of the parameter
* @param { string } value - The value of the parameter.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
* @example : Set(ImageVideoKey.TITLE, "newTitle"), call commitModify after set value
*/
set(member: string, value: string): void;
/**
* Modify meta data where the file is located.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO
* @param { AsyncCallback<void> } callback - No value will be returned.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
commitModify(callback: AsyncCallback<void>): void;
/**
* Modify meta data where the file is located.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO
* @returns { Promise<void> } Return promise
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
commitModify(): Promise<void>;
/**
* Open local file.
*
* @permission ohos.permission.READ_IMAGEVIDEO or ohos.permission.READ_AUDIO or ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO
* @param { string } mode - Mode for open, for example: rw, r, w.
* @param { AsyncCallback<number> } callback - Callback return the fd of the file.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
open(mode: string, callback: AsyncCallback<number>): void;
/**
* Open local file.
*
* @permission ohos.permission.READ_IMAGEVIDEO or ohos.permission.READ_AUDIO or ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO
* @param { string } mode - Mode for open, for example: rw, r, w.
* @returns { Promise<number> } Return promise
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
open(mode: string): Promise<number>;
/**
* Close the file is located.
*
* @param { number } fd - Fd of the file which had been opened
* @param { AsyncCallback<void> } callback - No value will be returned.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
close(fd: number, callback: AsyncCallback<void>): void;
/**
* Close the file is located.
*
* @param { number } fd - Fd of the file which had been opened
* @returns { Promise<void> } Return promise
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
close(fd: number): Promise<void>;
/**
* Get thumbnail of the file when the file is located.
*
* @permission ohos.permission.READ_IMAGEVIDEO or ohos.permission.READ_AUDIO
* @param { AsyncCallback<image.PixelMap> } callback - Callback used to return the thumbnail's pixelMap.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getThumbnail(callback: AsyncCallback<image.PixelMap>): void;
/**
* Get thumbnail of the file when the file is located.
*
* @permission ohos.permission.READ_IMAGEVIDEO or ohos.permission.READ_AUDIO
* @param { image.Size } size - Thumbnail's size
* @param { AsyncCallback<image.PixelMap> } callback - Callback used to return the thumbnail's pixelMap.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getThumbnail(size: image.Size, callback: AsyncCallback<image.PixelMap>): void;
/**
* Get thumbnail of the file when the file is located.
*
* @permission ohos.permission.READ_IMAGEVIDEO or ohos.permission.READ_AUDIO
* @param { image.Size } size - Thumbnail's size
* @returns { Promise<image.PixelMap> } Return promise
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getThumbnail(size?: image.Size): Promise<image.PixelMap>;
/**
* Set favorite for the file when the file is located.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO
* @param { boolean } isFavorite - True is favorite file, false is not favorite file
* @param { AsyncCallback<void> } callback - Callback used to return, No value is returned.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
favorite(isFavorite: boolean, callback: AsyncCallback<void>): void;
/**
* Set favorite for the file when the file is located.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO
* @param { boolean } isFavorite - isFavorite True is favorite file, false is not favorite file
* @returns { Promise<void> } Return promise
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
favorite(isFavorite: boolean): Promise<void>;
/**
* Set file hidden state.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { boolean } hiddenState - true: Put the asset into hidden album; false: Recover the asset from hidden album.
* @param { AsyncCallback<void> } callback - Return void.
* @throws { BusinessError } 202 - Called by non-system application.
* @throws { BusinessError } 13900020 - if parameter is invalid
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
setHidden(hiddenState: boolean, callback: AsyncCallback<void>): void;
/**
* Set file hidden state.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { boolean } hiddenState - true: Put the asset into hidden album; false: Recover the asset from hidden album.
* @returns { Promise<void> } Returns the promise
* @throws { BusinessError } 202 - Called by non-system application.
* @throws { BusinessError } 13900020 - if parameter is invalid
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
setHidden(hiddenState: boolean): Promise<void>;
/**
* Set user comment info to the asset.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { string } userComment - user comment info
* @param { AsyncCallback<void> } callback - Returns void.
* @throws { BusinessError } 202 - Called by non-system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
* <br>2. Incorrect parameter types; 3. Parameter verification failed.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
setUserComment(userComment: string, callback: AsyncCallback<void>): void;
/**
* Set user comment info to the asset.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { string } userComment - user comment info
* @returns { Promise<void> } Returns void
* @throws { BusinessError } 202 - Called by non-system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
* <br>2. Incorrect parameter types; 3. Parameter verification failed.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
setUserComment(userComment: string): Promise<void>;
/**
* Get exif info of the asset.
*
* @permission ohos.permission.READ_IMAGEVIDEO
* @param { AsyncCallback<string> } callback - Returns exif info into a json string
* @throws { BusinessError } 202 - Called by non-system application.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
getExif(callback: AsyncCallback<string>): void;
/**
* Get exif info of the asset.
*
* @permission ohos.permission.READ_IMAGEVIDEO
* @returns { Promise<string> } Returns exif info into a json string
* @throws { BusinessError } 202 - Called by non-system application.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
getExif(): Promise<string>;
}
/**
* Describes AUDIO TYPE FetchOptions's predicate
*
* @enum { string } AudioKey
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
enum AudioKey {
/**
* File uri, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
URI,
/**
* File name
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
DISPLAY_NAME,
/**
* Date of the file creation, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
DATE_ADDED,
/**
* Modify date of the file, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
DATE_MODIFIED,
/**
* Title of the file, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
TITLE,
/**
* Artist of the audio file, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
ARTIST,
/**
* Audio album of the audio file, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
AUDIOALBUM,
/**
* Duration of the audio file, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
DURATION,
/**
* Favorite state of the file, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
FAVORITE
}
/**
* Describes Image, Video TYPE FetchOptions's predicate
*
* @enum { string } ImageVideoKey
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
enum ImageVideoKey {
/**
* File uri, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
URI,
/**
* File type of the Asset, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
FILE_TYPE,
/**
* File name
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
DISPLAY_NAME,
/**
* Date of the file creation, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
DATE_ADDED,
/**
* Modify date of the file, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
DATE_MODIFIED,
/**
* Title of the file, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
TITLE,
/**
* Duration of the audio and video file, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
DURATION,
/**
* Width of the image file, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
WIDTH,
/**
* Height of the image file, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
HEIGHT,
/**
* Date taken of the file, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
DATE_TAKEN,
/**
* Orientation of the image file, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
ORIENTATION,
/**
* Favorite state of the file, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
FAVORITE,
/**
* File position, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
POSITION,
/**
* Trashed date of the file, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
DATE_TRASHED,
/**
* Hidden state of the file, read only
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
HIDDEN,
/**
* User comment info
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
USER_COMMENT,
/**
* Camera shot key
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
CAMERA_SHOT_KEY
}
/**
* Describes Album TYPE predicate
*
* @enum { string } AlbumKey
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
enum AlbumKey {
/**
* Album uri
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
URI,
/**
* File type of the Album
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
FILE_TYPE,
/**
* Album name
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
ALBUM_NAME,
/**
* Date of the Album creation
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
DATE_ADDED,
/**
* Modify date of the Album
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
DATE_MODIFIED
}
/**
* Fetch parameters
*
* @interface FetchOptions
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
interface FetchOptions {
/**
* Indicates the columns to query.
*
* @type { Array<string> }
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
fetchColumns: Array<string>;
/**
* Predicate to query
*
* @type { dataSharePredicates.DataSharePredicates }
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
predicates: dataSharePredicates.DataSharePredicates;
}
/**
* Fetch parameters
*
* @interface AlbumFetchOptions
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
interface AlbumFetchOptions {
/**
* Predicate to query
*
* @type { dataSharePredicates.DataSharePredicates }
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
predicates: dataSharePredicates.DataSharePredicates;
}
/**
* Describe additional operations for creating photo
*
* @interface PhotoCreateOptions
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
interface PhotoCreateOptions {
/**
* SubType of the photo
*
* @type { ?PhotoSubType }
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
subType?: PhotoSubType;
/**
* Camera shot key
*
* @type { ?string }
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
cameraShotKey?: string;
}
/**
* Implements file retrieval.
*
* @interface FetchResult
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
interface FetchResult<T> {
/**
* Obtains the total number of files in the file retrieval result.
*
* @returns { number } Total number of files.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getCount(): number;
/**
* Checks whether the result set points to the last row.
*
* @returns { boolean } Whether the file is the last one.
* You need to check whether the file is the last one before calling getNextObject,
* which returns the next file only when False is returned for this method.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
isAfterLast(): boolean;
/**
* Releases the FetchResult instance and invalidates it. Other methods cannot be called.
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
close(): void;
/**
* Obtains the first FileAsset in the file retrieval result. This method uses a callback to return the file.
*
* @param { AsyncCallback<T> } callback - Callback used to return the file in the format of a FileAsset instance.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getFirstObject(callback: AsyncCallback<T>): void;
/**
* Obtains the first T in the file retrieval result. This method uses a promise to return the file.
*
* @returns { Promise<T> } A Promise instance used to return the file in the format of a T instance.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getFirstObject(): Promise<T>;
/**
* Obtains the next T in the file retrieval result.
* This method uses a callback to return the file.
* Before calling this method, you must use isAfterLast() to check whether the result set points to the last row.
* This method returns the next file only when False is returned for isAfterLast().
*
* @param { AsyncCallback<T> } callback - Callback used to return the file in the format of a T instance.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getNextObject(callback: AsyncCallback<T>): void;
/**
* Obtains the next T in the file retrieval result.
* This method uses a promise to return the file.
* Before calling this method, you must use isAfterLast() to check whether the result set points to the last row.
* This method returns the next file only when False is returned for isAfterLast().
*
* @returns { Promise<T> } A Promise instance used to return the file in the format of a T instance.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getNextObject(): Promise<T>;
/**
* Obtains the last T in the file retrieval result. This method uses a callback to return the file.
*
* @param { AsyncCallback<T> } callback - Callback used to return the file in the format of a T instance.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getLastObject(callback: AsyncCallback<T>): void;
/**
* Obtains the last T in the file retrieval result. This method uses a promise to return the file.
*
* @returns { Promise<T> } A Promise instance used to return the file in the format of a T instance.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getLastObject(): Promise<T>;
/**
* Obtains the T with the specified index in the file retrieval result.
* This method uses a callback to return the file.
*
* @param { number } index - Index of the file to obtain.
* @param { AsyncCallback<T> } callback - Callback used to return the file in the format of a T instance.
* @throws { BusinessError } 13900020 - if type index is not number
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getPositionObject(index: number, callback: AsyncCallback<T>): void;
/**
* Obtains the T with the specified index in the file retrieval result.
* This method uses a promise to return the file.
*
* @param { number } index - Index of the file to obtain.
* @returns { Promise<T> } A Promise instance used to return the file in the format of a T instance.
* @throws { BusinessError } 13900020 - if type index is not number
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getPositionObject(index: number): Promise<T>;
/**
* Obtains all T in the file retrieval result.
* This method uses a callback to return the result. After this method is called,
*
* @param { AsyncCallback<Array<T>> } callback - Callback used to return a T array.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
getAllObject(callback: AsyncCallback<Array<T>>): void;
/**
* Obtains all T in the file retrieval result.
* This method uses a promise to return the result. that store the selected media resources.
*
* @returns { Promise<Array<T>> } A Promise instance used to return a T array.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
getAllObject(): Promise<Array<T>>;
}
/**
* Album type.
*
* @enum { number } AlbumType
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
enum AlbumType {
/**
* Album created by user.
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
USER = 0,
/**
* Album created by system, which metadata cannot be modified by user.
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
SYSTEM = 1024
}
/**
* Album subtype
*
* @enum { number } AlbumSubType
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
enum AlbumSubType {
/**
* Generic user-created albums.
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
USER_GENERIC = 1,
/**
* Favorite album, which assets are marked as favorite.
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
FAVORITE = 1025,
/**
* Video album, which contains all video assets.
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
VIDEO,
/**
* Hidden album, which assets are marked as hidden.
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
HIDDEN,
/**
* Trash album, which assets are deleted.
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
TRASH,
/**
* Screenshot album
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
SCREENSHOT,
/**
* Camera album
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
CAMERA,
/**
* Any album
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
ANY = 2147483647
}
/**
* Defines the AbsAlbum.
*
* @interface AbsAlbum
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
interface AbsAlbum {
/**
* Album type
*
* @type { AlbumType }
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
readonly albumType: AlbumType;
/**
* Album subtype
*
* @type { AlbumSubType }
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
readonly albumSubType: AlbumSubType;
/**
* Album name.
*
* @type { string }
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
albumName: string;
/**
* Album uri.
*
* @type { string }
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
readonly albumUri: string;
/**
* Date (timestamp) when the album was last modified.
*
* @type { number }
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
readonly dateModified: number;
/**
* File count for the album
*
* @type { number }
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
readonly count: number;
/**
* CoverUri for the album
*
* @type { string }
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
coverUri: string;
/**
* Obtains files in an album. This method uses an asynchronous callback to return the files.
*
* @permission ohos.permission.READ_IMAGEVIDEO
* @param { FetchOptions } options - Retrieval options.
* @param { AsyncCallback<FetchResult<FileAsset>> } callback - Callback used to return the files in the format of a FetchResult instance.
* @throws { BusinessError } 13900020 - if type options is not FetchOptions
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getPhotoAssets(options: FetchOptions, callback: AsyncCallback<FetchResult<FileAsset>>): void;
/**
* Obtains files in an album. This method uses a promise to return the files.
*
* @permission ohos.permission.READ_IMAGEVIDEO
* @param { FetchOptions } options - Retrieval options.
* @returns { Promise<FetchResult<FileAsset>> } A Promise instance used to return the files in the format of a FetchResult instance.
* @throws { BusinessError } 13900020 - if type options is not FetchOptions
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getPhotoAssets(options: FetchOptions): Promise<FetchResult<FileAsset>>;
}
/**
* Defines the album.
*
* @interface Album
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
interface Album extends AbsAlbum {
/**
* Modify the meta data for the album
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { AsyncCallback<void> } callback - No value will be returned.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
commitModify(callback: AsyncCallback<void>): void;
/**
* Modify the meta data for the album
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @returns { Promise<void> } Return promise
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
commitModify(): Promise<void>;
/**
* Add PhotoAssets to the album.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { Array<FileAsset> } assets - Assets to add
* @param { AsyncCallback<void> } callback - Returns void
* @throws { BusinessError } 13900020 - if PhotoAssets is invalid
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
addPhotoAssets(assets: Array<FileAsset>, callback: AsyncCallback<void>): void;
/**
* Add PhotoAssets to the album.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { Array<FileAsset> } assets - Assets to add
* @returns { Promise<void> } Returns the promise
* @throws { BusinessError } 13900020 - if PhotoAssets is invalid
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
addPhotoAssets(assets: Array<FileAsset>): Promise<void>;
/**
* Remove PhotoAssets from the album.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { Array<FileAsset> } assets - Assets to remove
* @param { AsyncCallback<void> } callback - Returns void
* @throws { BusinessError } 13900020 - if PhotoAssets is invalid
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
removePhotoAssets(assets: Array<FileAsset>, callback: AsyncCallback<void>): void;
/**
* Remove PhotoAssets from the album.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { Array<FileAsset> } assets - Assets to remove
* @returns { Promise<void> } Returns the promise
* @throws { BusinessError } 13900020 - if PhotoAssets is invalid
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
removePhotoAssets(assets: Array<FileAsset>): Promise<void>;
/**
* Recover PhotoAssets from the trash album.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { Array<FileAsset> } assets - Assets to recover
* @param { AsyncCallback<void> } callback - Returns void
* @throws { BusinessError } 13900020 - if PhotoAssets is invalid
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
recoverPhotoAssets(assets: Array<FileAsset>, callback: AsyncCallback<void>): void;
/**
* Recover PhotoAssets from the trash album.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { Array<FileAsset> } assets - Assets to recover
* @returns { Promise<void> } Returns the promise
* @throws { BusinessError } 13900020 - if PhotoAssets is invalid
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
recoverPhotoAssets(assets: Array<FileAsset>): Promise<void>;
/**
* Delete PhotoAssets permanently from the trash album.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { Array<FileAsset> } assets - Assets to delete
* @param { AsyncCallback<void> } callback - Returns void
* @throws { BusinessError } 13900020 - if PhotoAssets is invalid
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
deletePhotoAssets(assets: Array<FileAsset>, callback: AsyncCallback<void>): void;
/**
* Delete PhotoAssets permanently from the trash album.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { Array<FileAsset> } assets - Assets to delete
* @returns { Promise<void> } Returns the promise
* @throws { BusinessError } 13900020 - if PhotoAssets is invalid
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
deletePhotoAssets(assets: Array<FileAsset>): Promise<void>;
}
/**
* Defines the UserFileManager class and provides functions to access the data in user file storage.
*
* @interface UserFileManager
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
interface UserFileManager {
/**
* Query photo, video assets
*
* @permission ohos.permission.READ_IMAGEVIDEO
* @param { FetchOptions } options - retrieval options.
* @param { AsyncCallback<FetchResult<FileAsset>> } callback - Callback return the FetchResult.
* @throws { BusinessError } 13900020 - if type options is not FetchOptions
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getPhotoAssets(options: FetchOptions, callback: AsyncCallback<FetchResult<FileAsset>>): void;
/**
* Query photo, video assets
*
* @permission ohos.permission.READ_IMAGEVIDEO
* @param { FetchOptions } options - Retrieval options.
* @returns { Promise<FetchResult<FileAsset>> } A promise instance used to return the files in the format of a FetchResult instance
* @throws { BusinessError } 13900020 - if type options is not FetchOptions
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getPhotoAssets(options: FetchOptions): Promise<FetchResult<FileAsset>>;
/**
* Create Photo Asset
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { string } displayName - File name
* @param { string } albumUri - Asset will put into the album.
* @param { AsyncCallback<FileAsset> } callback - Callback used to return the FileAsset
* @throws { BusinessError } 13900020 - if type displayName or albumUri is not string
* @throws { BusinessError } 14000001 - if type displayName invalid
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
createPhotoAsset(displayName: string, albumUri: string, callback: AsyncCallback<FileAsset>): void;
/**
* Create Photo Asset
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { string } displayName - File name
* @param { AsyncCallback<FileAsset> } callback - Callback used to return the FileAsset
* @throws { BusinessError } 13900020 - if type displayName is not string
* @throws { BusinessError } 14000001 - if type displayName invalid
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
createPhotoAsset(displayName: string, callback: AsyncCallback<FileAsset>): void;
/**
* Create Photo Asset
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { string } displayName - File name
* @param { string } albumUri - Album uri is optional, PhotoAssets will put into the default album without albumUri
* @returns { Promise<FileAsset> } A Promise instance used to return the FileAsset
* @throws { BusinessError } 13900020 - if type displayName or albumUri is not string
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
createPhotoAsset(displayName: string, albumUri?: string): Promise<FileAsset>;
/**
* Create Photo Asset
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { string } displayName - File name
* @param { PhotoCreateOptions } createOption - Create operation
* @returns { Promise<FileAsset> } A Promise instance used to return the FileAsset
* @throws { BusinessError } 13900020 - if type displayName is not string
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
createPhotoAsset(displayName: string, createOption: PhotoCreateOptions): Promise<FileAsset>;
/**
* Create Photo Asset
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { string } displayName - File name
* @param { PhotoCreateOptions } createOption - Photo create operation
* @param { AsyncCallback<FileAsset> } callback - Callback used to return the FileAsset
* @throws { BusinessError } 13900020 - if type displayName is not string
* @throws { BusinessError } 14000001 - if type displayName invalid
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
createPhotoAsset(displayName: string, createOption: PhotoCreateOptions, callback: AsyncCallback<FileAsset>): void;
/**
* Create Audio Asset
*
* @permission ohos.permission.WRITE_AUDIO
* @param { string } displayName - File name
* @param { AsyncCallback<FileAsset> } callback - Callback used to return the FileAsset
* @throws { BusinessError } 13900020 - if type displayName is not string
* @throws { BusinessError } 14000001 - if type displayName invalid
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
createAudioAsset(displayName: string, callback: AsyncCallback<FileAsset>): void;
/**
* Create Audio Asset
*
* @permission ohos.permission.WRITE_AUDIO
* @param { string } displayName - File name
* @returns { Promise<FileAsset> } A Promise instance used to return the FileAsset
* @throws { BusinessError } 13900020 - if type displayName is not string
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
createAudioAsset(displayName: string): Promise<FileAsset>;
/**
* Obtains albums based on the retrieval options. This method uses an asynchronous callback to return.
*
* @permission ohos.permission.READ_IMAGEVIDEO
* @param { AlbumFetchOptions } options - Retrieval options.
* @param { AsyncCallback<FetchResult<Album>> } callback - Callback used to return an album array.
* @throws { BusinessError } 13900020 - if type options is not AlbumFetchOptions
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getPhotoAlbums(options: AlbumFetchOptions, callback: AsyncCallback<FetchResult<Album>>): void;
/**
* Obtains albums based on the retrieval options. This method uses a promise to return the albums.
*
* @permission ohos.permission.READ_IMAGEVIDEO
* @param { AlbumFetchOptions } options - Retrieval options.
* @returns { Promise<FetchResult<Album>> } A Promise instance used to return an album array.
* @throws { BusinessError } 13900020 - if type options is not AlbumFetchOptions
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getPhotoAlbums(options: AlbumFetchOptions): Promise<FetchResult<Album>>;
/**
* Create a generic user album.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { string } name - Album name to be created.
* @param { AsyncCallback<Album> } callback - Returns the instance of newly created Album
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
createAlbum(name: string, callback: AsyncCallback<Album>): void;
/**
* Create a generic user album.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { string } name - Album name to be created.
* @returns { Promise<Album> } Returns the instance of newly created Album
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
createAlbum(name: string): Promise<Album>;
/**
* Delete generic user-created albums.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { Array<Album> } albums - Specify which album to delete
* @param { AsyncCallback<void> } callback - Returns void
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
deleteAlbums(albums: Array<Album>, callback: AsyncCallback<void>): void;
/**
* Delete generic user-created albums.
*
* @permission ohos.permission.WRITE_IMAGEVIDEO
* @param { Array<Album> } albums - Specify which album to delete
* @returns { Promise<void> } Returns the promise
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
deleteAlbums(albums: Array<Album>): Promise<void>;
/**
* Obtains albums based on the retrieval options and album types.
*
* @permission ohos.permission.READ_IMAGEVIDEO
* @param { AlbumType } type - Album type.
* @param { AlbumSubType } subType - Album subtype.
* @param { FetchOptions } options - options to fetch albums
* @param { AsyncCallback<FetchResult<Album>> } callback - Returns the fetch result of the albums
* @throws { BusinessError } 13900020 - if type options is not FetchOption
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
getAlbums(
type: AlbumType,
subType: AlbumSubType,
options: FetchOptions,
callback: AsyncCallback<FetchResult<Album>>
): void;
/**
* Obtains albums based on the album types.
*
* @permission ohos.permission.READ_IMAGEVIDEO
* @param { AlbumType } type - Album type.
* @param { AlbumSubType } subType - Album subtype.
* @param { AsyncCallback<FetchResult<Album>> } callback - Returns the fetch result of the albums
* @throws { BusinessError } 13900020 - if type options is not FetchOption
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
getAlbums(type: AlbumType, subType: AlbumSubType, callback: AsyncCallback<FetchResult<Album>>): void;
/**
* Obtains albums based on the retrieval options and album types.
*
* @permission ohos.permission.READ_IMAGEVIDEO
* @param { AlbumType } type - Album type.
* @param { AlbumSubType } subType - Album subtype.
* @param { FetchOptions } [options] -options to fetch albums
* @returns { Promise<FetchResult<Album>> } - Returns the fetch result of the albums
* @throws { BusinessError } 13900020 - if type options is not FetchOption
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
getAlbums(type: AlbumType, subType: AlbumSubType, options?: FetchOptions): Promise<FetchResult<Album>>;
/**
* Obtains system private albums based on the private album type. This method uses an asynchronous callback to return.
*
* @permission ohos.permission.READ_IMAGEVIDEO
* @param { PrivateAlbumType } type - Private album type
* @param { AsyncCallback<FetchResult<PrivateAlbum>> } callback - Used to return a private album FetchResult.
* @throws { BusinessError } 13900020 - if type type is not PrivateAlbumType
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getPrivateAlbum(type: PrivateAlbumType, callback: AsyncCallback<FetchResult<PrivateAlbum>>): void;
/**
* Obtains system private albums based on the private album type. This method uses a promise to return.
*
* @permission ohos.permission.READ_IMAGEVIDEO
* @param { PrivateAlbumType } type - Private album type
* @returns { Promise<FetchResult<PrivateAlbum>> } A Promise instance used to return a private album FetchResult.
* @throws { BusinessError } 13900020 - if type type is not PrivateAlbumType
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getPrivateAlbum(type: PrivateAlbumType): Promise<FetchResult<PrivateAlbum>>;
/**
* Query audio assets
*
* @permission ohos.permission.READ_AUDIO
* @param { FetchOptions } options - Retrieval options.
* @param { AsyncCallback<FetchResult<FileAsset>> } callback - Callback return the FetchResult.
* @throws { BusinessError } 13900020 - if type options is not FetchOptions
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getAudioAssets(options: FetchOptions, callback: AsyncCallback<FetchResult<FileAsset>>): void;
/**
* Query audio assets
*
* @permission ohos.permission.READ_AUDIO
* @param { FetchOptions } options - Retrieval options.
* @returns { Promise<FetchResult<FileAsset>> } A promise instance used to return the files in the format of a FetchResult instance
* @throws { BusinessError } 13900020 - if type options is not FetchOptions
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
getAudioAssets(options: FetchOptions): Promise<FetchResult<FileAsset>>;
/**
* Delete Asset
*
* @permission ohos.permission.READ_IMAGEVIDEO and ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO and ohos.permission.WRITE_AUDIO
* @param { string } uri - Uri of FileAsset
* @param { AsyncCallback<void> } callback - No value returned
* @throws { BusinessError } 13900020 - if type uri is not string
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
delete(uri: string, callback: AsyncCallback<void>): void;
/**
* Delete Asset
*
* @permission ohos.permission.READ_IMAGEVIDEO and ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO and ohos.permission.WRITE_AUDIO
* @param { string } uri - Uri of FileAsset
* @returns { Promise<void> } A Promise instance, no value returned
* @throws { BusinessError } 13900020 - if type uri is not string
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
delete(uri: string): Promise<void>;
/**
* Get the index of the asset in the album
*
* @permission ohos.permission.READ_IMAGEVIDEO
* @param { string } photoUri - The photo asset uri.
* @param { string } albumUri - The album uri.
* @param { FetchOptions } options - fetch options
* @param { AsyncCallback<number> } callback - Returns the index of the asset in the album
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
* <br>2. Incorrect parameter types; 3. Parameter verification failed.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions, callback: AsyncCallback<number>): void;
/**
* Get the index of the asset in the album
*
* @permission ohos.permission.READ_IMAGEVIDEO
* @param { string } photoUri - The photo asset uri.
* @param { string } albumUri - The album uri.
* @param { FetchOptions } options - fetch options
* @returns { Promise<number> } - Returns the index of the asset in the album
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
* <br>2. Incorrect parameter types; 3. Parameter verification failed.
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
getPhotoIndex(photoUri: string, albumUri: string, options: FetchOptions): Promise<number>;
/**
* Turn on monitor the data changes
*
* @param { ChangeEvent } type - One of 'deviceChange','albumChange','imageChange','audioChange','videoChange','remoteFileChange'
* @param { Callback<void> } callback - No value returned
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
on(type: ChangeEvent, callback: Callback<void>): void;
/**
* Turn off monitor the data changes
*
* @param { ChangeEvent } type - One of 'deviceChange','albumChange','imageChange','audioChange','videoChange','remoteFileChange'
* @param { Callback<void> } callback - No value returned
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
off(type: ChangeEvent, callback?: Callback<void>): void;
/**
* Turn on monitor for the specified uri.
*
* @param { string } uri - FileAsset's uri, album's uri or DefaultChangeUri
* @param { boolean } forSubUri - Monitor the sub uri.
* @param { Callback<ChangeData> } callback - callback function, return the ChangeData to be monitored
* @throws { BusinessError } 13900020 - if parameter is invalid
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
on(uri: string, forSubUri: boolean, callback: Callback<ChangeData>): void;
/**
* Turn off monitor for the specified uri.
*
* @param { string } uri - FileAsset's uri, Album's uri or DefaultChangeUri value
* @param { Callback<ChangeData> } [callback] - Remove specified callback from monitoring to a specified uri
* @throws { BusinessError } 13900020 - if parameter is invalid
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
off(uri: string, callback?: Callback<ChangeData>): void;
/**
* Get Active Peer device information
*
* @param { AsyncCallback<Array<PeerInfo>> } callback - Callback return the list of the active peer devices' information
* @syscap SystemCapability.FileManagement.UserFileManager.DistributedCore
* @systemapi
* @since 9
*/
getActivePeers(callback: AsyncCallback<Array<PeerInfo>>): void;
/**
* Get Active Peer device information
*
* @returns { Promise<Array<PeerInfo>> } Promise used to return the list of the active peer devices' information
* @syscap SystemCapability.FileManagement.UserFileManager.DistributedCore
* @systemapi
* @since 9
*/
getActivePeers(): Promise<Array<PeerInfo>>;
/**
* Get all the peer devices' information
*
* @param { AsyncCallback<Array<PeerInfo>> } callback - Callback return the list of the all the peer devices' information
* @syscap SystemCapability.FileManagement.UserFileManager.DistributedCore
* @systemapi
* @since 9
*/
getAllPeers(callback: AsyncCallback<Array<PeerInfo>>): void;
/**
* Get all the peer devices' information
*
* @returns { Promise<Array<PeerInfo>> } Promise used to return the list of the all the peer devices' information
* @syscap SystemCapability.FileManagement.UserFileManager.DistributedCore
* @systemapi
* @since 9
*/
getAllPeers(): Promise<Array<PeerInfo>>;
/**
* Release UserFileManager instance
*
* @param { AsyncCallback<void> } callback - No value returned
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
release(callback: AsyncCallback<void>): void;
/**
* Release UserFileManager instance
*
* @returns { Promise<void> } Return promise
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
release(): Promise<void>;
}
/**
* NotifyType subtype
*
* @enum { number } NotifyType subtype
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
enum NotifyType {
/**
* Type for add notification of the FileAsset or Album
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
NOTIFY_ADD,
/**
* Type for update notification of the FileAsset or Album
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
NOTIFY_UPDATE,
/**
* Type for remove notification of the FileAsset or Album
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
NOTIFY_REMOVE,
/**
* Type for notification of the FileAsset added at an Album
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
NOTIFY_ALBUM_ADD_ASSET,
/**
* Type for notification of the FileAsset removed at an Album
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
NOTIFY_ALBUM_REMOVE_ASSET
}
/**
* DefaultChangeUri subtype
*
* @enum { string } DefaultChangeUri subtype
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
enum DefaultChangeUri {
/**
* Uri for default PhotoAsset, use with forDescendant{true}, will recieve all PhotoAsset's change notifications
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
DEFAULT_PHOTO_URI,
/**
* Uri for default Album, use with forDescendant{true}, will recieve all Album's change notifications
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
DEFAULT_ALBUM_URI,
/**
* Uri for default AudioAsset, use with forDescendant{true}, will recieve all AudioAsset's change notifications
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
DEFAULT_AUDIO_URI
}
/**
* the value of the monitor callback function
*
* @interface ChangeData
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
interface ChangeData {
/**
* the NotifyType of ChangeData
*
* @type { NotifyType }
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
type: NotifyType;
/**
* all uris of the same NotifyType, could be FileAssets' or Albums'
*
* @type { Array<string> }
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
uris: Array<string>;
/**
* change details of the Album's FileAssets when uris is the Album's uri type
*
* @type { Array<string> }
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 10
*/
subUris: Array<string>;
}
/**
* Peer devices' information
*
* @interface PeerInfo
* @syscap SystemCapability.FileManagement.UserFileManager.DistributedCore
* @systemapi
* @since 9
*/
interface PeerInfo {
/**
* Peer device name
*
* @type { string }
* @syscap SystemCapability.FileManagement.UserFileManager.DistributedCore
* @systemapi
* @since 9
*/
readonly deviceName: string;
/**
* Peer device network id
*
* @type { string }
* @syscap SystemCapability.FileManagement.UserFileManager.DistributedCore
* @systemapi
* @since 9
*/
readonly networkId: string;
/**
* Peer device online status
*
* @type { boolean }
* @syscap SystemCapability.FileManagement.UserFileManager.DistributedCore
* @systemapi
* @since 9
*/
readonly isOnline: boolean;
}
/**
* Private album type
*
* @enum { string } PrivateAlbumType
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
enum PrivateAlbumType {
/**
* System Private Album: Favorite album
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
TYPE_FAVORITE,
/**
* System Private Album: Trash album
*
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
TYPE_TRASH
}
/**
* Defines the private album
*
* @interface PrivateAlbum
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
interface PrivateAlbum extends AbsAlbum {
/**
* Delete asset permanently from Trash bin, only support the Trash album
*
* @permission ohos.permission.READ_IMAGEVIDEO and ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO and ohos.permission.WRITE_AUDIO
* @param { string } uri - uri of asset
* @param { AsyncCallback<void> } callback - No value returned
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
delete(uri: string, callback: AsyncCallback<void>): void;
/**
* Delete asset permanently from Trash bin, only support the Trash album
*
* @permission ohos.permission.READ_IMAGEVIDEO and ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO and ohos.permission.WRITE_AUDIO
* @param { string } uri - Uri of asset
* @returns { Promise<void> } A Promise instance, no value returned
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
delete(uri: string): Promise<void>;
/**
* Recover asset from Trash bin, only support the Trash album
*
* @permission ohos.permission.READ_IMAGEVIDEO and ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO and ohos.permission.WRITE_AUDIO
* @param { string } uri - Uri of asset
* @param { AsyncCallback<void> } callback - No value returned
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
recover(uri: string, callback: AsyncCallback<void>): void;
/**
* Recover asset from Trash bin, only support the Trash album
*
* @permission ohos.permission.READ_IMAGEVIDEO and ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO and ohos.permission.WRITE_AUDIO
* @param { string } uri - Uri of asset
* @returns { Promise<void> } A Promise instance, no value returned
* @syscap SystemCapability.FileManagement.UserFileManager.Core
* @systemapi
* @since 9
*/
recover(uri: string): Promise<void>;
}
}
export default userFileManager;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lffl8796/interface_sdk-js.git
git@gitee.com:lffl8796/interface_sdk-js.git
lffl8796
interface_sdk-js
interface_sdk-js
master

搜索帮助