40 Star 163 Fork 4.4K

OpenHarmony/interface_sdk-js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
@ohos.file.picker.d.ts 48.82 KB
一键复制 编辑 原始数据 按行查看 历史
zhouoaoteng 提交于 1个月前 . fix;doc
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331
/*
* Copyright (c) 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 { AsyncCallback, Callback } from './@ohos.base';
import Context from './application/Context';
import window from './@ohos.window';
import type { CustomColors } from './@ohos.arkui.theme';
/**
* The Picker module encapsulates APIs of DocumentViewPicker, AudioViewPicker, and PhotoViewPicker
* to provide capabilities of selecting and saving files of different types.
* An application can select the API as required. The APIs of this module must be called in UIAbility.
* Otherwise, the FilePicker, AudioPicker, or PhotoPicker cannot be started.
* Chinese characters and non-digit characters in the path are compiled into the corresponding ASCII code
* and concatenated to the URI returned by calling these APIs.
*
* @namespace picker
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* The Picker module encapsulates APIs of DocumentViewPicker, AudioViewPicker, and PhotoViewPicker
* to provide capabilities of selecting and saving files of different types.
* An application can select the API as required. The APIs of this module must be called in UIAbility.
* Otherwise, the FilePicker, AudioPicker, or PhotoPicker cannot be started.
* Chinese characters and non-digit characters in the path are compiled into the corresponding ASCII code
* and concatenated to the URI returned by calling these APIs.
*
* @namespace picker
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 11
*/
/**
* The Picker module encapsulates APIs of DocumentViewPicker, AudioViewPicker, and PhotoViewPicker
* to provide capabilities of selecting and saving files of different types.
* An application can select the API as required. The APIs of this module must be called in UIAbility.
* Otherwise, the FilePicker, AudioPicker, or PhotoPicker cannot be started.
* Chinese characters and non-digit characters in the path are compiled into the corresponding ASCII code
* and concatenated to the URI returned by calling these APIs.
*
* @namespace picker
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
declare namespace picker {
/**
* Enumerates the media file types that can be selected.
*
* @enum { string } PhotoViewMIMETypes
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Enumerates the media file types that can be selected.
*
* @enum { string } PhotoViewMIMETypes
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 11
* @deprecated since 12
* @useinstead ohos.file.photoAccessHelper/photoAccessHelper#PhotoViewMIMETypes
*/
export enum PhotoViewMIMETypes {
/**
* Image type.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Image type.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 11
* @deprecated since 18
* @useinstead ohos.file.photoAccessHelper/photoAccessHelper#PhotoViewMIMETypes.IMAGE_TYPE
*/
IMAGE_TYPE = 'image/*',
/**
* Video type.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Video type.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 11
* @deprecated since 18
* @useinstead ohos.file.photoAccessHelper/photoAccessHelper#PhotoViewMIMETypes.VIDEO_TYPE
*/
VIDEO_TYPE = 'video/*',
/**
* Image and video type.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Image and video type.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 11
* @deprecated since 18
* @useinstead ohos.file.photoAccessHelper/photoAccessHelper#PhotoViewMIMETypes.IMAGE_VIDEO_TYPE
*/
IMAGE_VIDEO_TYPE = '*/*'
}
/**
* Defines the options for selecting images/videos.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Defines the options for selecting images/videos.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 11
* @deprecated since 12
* @useinstead ohos.file.photoAccessHelper/photoAccessHelper#PhotoSelectOptions
*/
class PhotoSelectOptions {
/**
* Media file types to select. IMAGE_VIDEO_TYPE is used by default.
*
* @type { ?PhotoViewMIMETypes }
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Media file types to select. IMAGE_VIDEO_TYPE is used by default.
*
* @type { ?PhotoViewMIMETypes }
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 11
* @deprecated since 18
* @useinstead ohos.file.photoAccessHelper/photoAccessHelper#PhotoSelectOptions.MIMEType
*/
MIMEType?: PhotoViewMIMETypes;
/**
* Maximum number of media files that can be selected.
* The default value is 50, and the maximum value is 500.
*
* @type { ?number }
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Maximum number of media files that can be selected.
* The default value is 50, and the maximum value is 500.
*
* @type { ?number }
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 11
* @deprecated since 18
* @useinstead ohos.file.photoAccessHelper/photoAccessHelper#PhotoSelectOptions.maxSelectNumber
*/
maxSelectNumber?: number;
}
/**
* Defines information about the images or videos selected.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Defines information about the images or videos selected.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 11
* @deprecated since 12
* @useinstead ohos.file.photoAccessHelper/photoAccessHelper#PhotoSelectResult
*/
class PhotoSelectResult {
/**
* URIs of the media files selected.
* This URI array can be used only by photoAccessHelper.getAssets. For details, see Using a Media File URI.
*
* @type { Array<string> }
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* URIs of the media files selected.
* This URI array can be used only by photoAccessHelper.getAssets. For details, see Using a Media File URI.
*
* @type { Array<string> }
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 11
* @deprecated since 18
* @useinstead ohos.file.photoAccessHelper/photoAccessHelper#PhotoSelectResult.photoUris
*/
photoUris: Array<string>;
/**
* Whether the selected image is the original one.
* The value true means the selected image is the original one; the value false means the opposite.
*
* @type { boolean }
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Whether the selected image is the original one.
* The value true means the selected image is the original one; the value false means the opposite.
*
* @type { boolean }
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 11
* @deprecated since 18
* @useinstead ohos.file.photoAccessHelper/photoAccessHelper#PhotoSelectResult.isOriginalPhoto
*/
isOriginalPhoto: boolean;
}
/**
* Defines the options for saving images or videos.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
* @deprecated since 12
*/
class PhotoSaveOptions {
/**
* File names of the images or videos to save. If this parameter is not specified, the user needs to enter the file names.
*
* @type { ?Array<string> }
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
* @deprecated since 18
*/
newFileNames?: Array<string>;
}
/**
* Provides APIs for selecting and saving images or videos.
* You are advised to use PhotoViewPicker of PhotoAccessHelper to select files.
* Before using the APIs of PhotoViewPicker, you need to create a PhotoViewPicker instance.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Provides APIs for selecting and saving images or videos.
* You are advised to use PhotoViewPicker of PhotoAccessHelper to select files.
* Before using the APIs of PhotoViewPicker, you need to create a PhotoViewPicker instance.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 11
* @deprecated since 12
* @useinstead ohos.file.photoAccessHelper/photoAccessHelper#PhotoViewPicker
*/
class PhotoViewPicker {
/**
* A constructor used to create a PhotoViewPicker instance.
* This constructor is not recommended due to the potential risk of operation failure.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 12
* @deprecated since 18
*/
constructor();
/**
* A constructor used to create a PhotoViewPicker instance. This constructor is recommended.
* For details about how to obtain the context, see getHostContext.
*
* @param { Context } context - represents the context.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 12
* @deprecated since 18
*/
constructor(context: Context);
/**
* Starts a photoPicker page for the user to select one or more images or videos.
* This API uses a promise to return the result.
* You can pass in PhotoSelectOptions to specify the type and maximum number of the files to select.
*
* @param { PhotoSelectOptions } option - Options for selecting images or videos.
* If this parameter is not specified, images and videos are selected by default.
* A maximum of 50 files can be selected.
* @returns { Promise<PhotoSelectResult> } Promise used to return the URIs of the images or videos selected.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Starts a photoPicker page for the user to select one or more images or videos.
* This API uses a promise to return the result.
* You can pass in PhotoSelectOptions to specify the type and maximum number of the files to select.
*
* @param { PhotoSelectOptions } option - Options for selecting images or videos.
* If this parameter is not specified, images and videos are selected by default.
* A maximum of 50 files can be selected.
* @returns { Promise<PhotoSelectResult> } Promise used to return the URIs of the images or videos selected.
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 11
* @deprecated since 12
* @useinstead ohos.file.photoAccessHelper/photoAccessHelper.PhotoViewPicker#select
*/
select(option?: PhotoSelectOptions): Promise<PhotoSelectResult>;
/**
* Starts a photoPicker page for the user to select one or more images or videos.
* This API uses an asynchronous callback to return the result.
* You can pass in PhotoSelectOptions to specify the type and maximum number of the files to select.
*
* @param { PhotoSelectOptions } option - Options for selecting images or videos.
* @param { AsyncCallback<PhotoSelectResult> } callback - Callback used to return the images or videos selected.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Starts a photoPicker page for the user to select one or more images or videos.
* This API uses an asynchronous callback to return the result.
* You can pass in PhotoSelectOptions to specify the type and maximum number of the files to select.
*
* @param { PhotoSelectOptions } option - Options for selecting images or videos.
* @param { AsyncCallback<PhotoSelectResult> } callback - Callback used to return the images or videos selected.
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 11
* @deprecated since 12
* @useinstead ohos.file.photoAccessHelper/photoAccessHelper.PhotoViewPicker#select
*/
select(option: PhotoSelectOptions, callback: AsyncCallback<PhotoSelectResult>): void;
/**
* Starts a photoPicker page for the user to select one or more images or videos.
* This API uses an asynchronous callback to return the result.
*
* @param { AsyncCallback<PhotoSelectResult> } callback - Callback used to return the images or videos selected.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Starts a photoPicker page for the user to select one or more images or videos.
* This API uses an asynchronous callback to return the result.
*
* @param { AsyncCallback<PhotoSelectResult> } callback - Callback used to return the images or videos selected.
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 11
* @deprecated since 12
* @useinstead ohos.file.photoAccessHelper/photoAccessHelper.PhotoViewPicker#select
*/
select(callback: AsyncCallback<PhotoSelectResult>): void;
/**
* Starts a photoPicker page for the user to save one or more images or videos.
* This API uses a promise to return the result.
* You can pass in PhotoSaveOptions to specify the URIs of the images or videos to save.
*
* @param { PhotoSaveOptions } option - Options for saving images or videos. If this parameter is not specified,
* a photoPicker page will be displayed for the user to enter the names of the files to save.
* @returns { Promise<Array<string>> } Returns the uris for the saved files.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
* @deprecated since 12
* @useinstead save_button/SaveButton
*/
save(option?: PhotoSaveOptions): Promise<Array<string>>;
/**
* Starts a photoPicker page for the user to save one or more images or videos.
* This API uses an asynchronous callback to return the result.
* You can pass in PhotoSaveOptions to specify the URIs of the images or videos to save.
*
* @param { PhotoSaveOptions } option - Options for saving images or videos.
* @param { AsyncCallback<Array<string>> } callback - Callback invoked to return the URIs of the images or videos saved.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
* @deprecated since 12
* @useinstead save_button/SaveButton
*/
save(option: PhotoSaveOptions, callback: AsyncCallback<Array<string>>): void;
/**
* Starts a photoPicker page for the user to save one or more images or videos.
* This API uses an asynchronous callback to return the URIs of the images or videos to save.
*
* @param { AsyncCallback<Array<string>> } callback - Callback invoked to return the URIs of the images or videos saved.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
* @deprecated since 12
* @useinstead save_button/SaveButton
*/
save(callback: AsyncCallback<Array<string>>): void;
}
/**
* Enumerates the types of documents selected.
* Only 2-in-1 devices are supported.
*
* @enum { number } DocumentSelectMode
* @syscap SystemCapability.FileManagement.UserFileService.FolderSelection
* @since 11
*/
/**
* Enumerates the types of documents selected.
* Only 2-in-1 devices are supported.
*
* @enum { number } DocumentSelectMode
* @syscap SystemCapability.FileManagement.UserFileService.FolderSelection
* @crossplatform
* @atomicservice
* @since 12
*/
export enum DocumentSelectMode {
/**
* File (default).
* Indicates that only files are allowed to be selected.
*
* @syscap SystemCapability.FileManagement.UserFileService.FolderSelection
* @since 11
*/
/**
* File (default).
* Indicates that only files are allowed to be selected.
*
* @syscap SystemCapability.FileManagement.UserFileService.FolderSelection
* @crossplatform
* @atomicservice
* @since 12
*/
FILE = 0,
/**
* Folder.
* Indicates that only folders are allowed to be selected.
*
* @syscap SystemCapability.FileManagement.UserFileService.FolderSelection
* @since 11
*/
/**
* Folder.
* Indicates that only folders are allowed to be selected.
*
* @syscap SystemCapability.FileManagement.UserFileService.FolderSelection
* @crossplatform
* @atomicservice
* @since 12
*/
FOLDER = 1,
/**
* Mixed type of files and folders.
* Indicates that files and folders are allowed to be selected.
*
* @syscap SystemCapability.FileManagement.UserFileService.FolderSelection
* @since 11
*/
/**
* Mixed type of files and folders.
* Indicates that files and folders are allowed to be selected.
*
* @syscap SystemCapability.FileManagement.UserFileService.FolderSelection
* @atomicservice
* @since 12
*/
MIXED = 2,
}
/**
* Enumerates the modes for saving documents.
*
* @enum { number } DocumentPickerMode
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 12
*/
export enum DocumentPickerMode {
/**
* Standard mode.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 12
*/
DEFAULT = 0,
/**
* Download mode.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 12
*/
DOWNLOAD = 1,
}
/**
* Enumerates file aggregation types. Only mobile phones are supported.
*
* @enum { number } DocumentPickerMode
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 15
*/
export enum MergeTypeMode {
/**
* Default mode, indicating that this parameter does not take effect.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 15
*/
DEFAULT = 0,
/**
* Audio mode.
* Indicates that audios are allowed to be selected
*
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 15
*/
AUDIO = 1,
/**
* Video mode.
* Indicates that videos are allowed to be selected
*
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 15
*/
VIDEO = 2,
/**
* Document mode.
* Indicates that documents are allowed to be selected
*
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 15
*/
DOCUMENT = 3,
/**
* Image mode.
* Indicates that pictures are allowed to be selected
*
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 15
*/
PICTURE = 4,
}
/**
* Defines the options for selecting documents.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Defines the options for selecting documents.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
class DocumentSelectOptions {
/**
* Path of the document or directory to select.
* It is empty by default (the recently opened page is displayed).
*
* @type { ?string }
* @syscap SystemCapability.FileManagement.UserFileService
* @since 10
*/
/**
* Path of the document or directory to select.
* It is empty by default (the recently opened page is displayed).
*
* @type { ?string }
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
defaultFilePathUri?: string;
/**
* Document suffix of the document to select. The value is a string array.
* Each element specifies an option, which includes at most two parts with a vertical bar (|) in between.
* The first part is the description, and the second part is the document suffix.
* If there is no "|", the option does not have the description.
* Multiple document suffixes separated by a comma (,) are allowed in an option.
* The number of elements in a string array cannot exceed 100.
* This parameter is available only to the devices that have the required system capability.
* By default, no filtering is performed, that is, all documents are selected.
*
* @type { ?Array<string> }
* @syscap SystemCapability.FileManagement.UserFileService
* @since 10
*/
/**
* Document suffix of the document to select. The value is a string array.
* Each element specifies an option, which includes at most two parts with a vertical bar (|) in between.
* The first part is the description, and the second part is the document suffix.
* If there is no "|", the option does not have the description.
* Multiple document suffixes separated by a comma (,) are allowed in an option.
* The number of elements in a string array cannot exceed 100.
* This parameter is available only to the devices that have the required system capability.
* By default, no filtering is performed, that is, all documents are selected.
*
* @type { ?Array<string> }
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
fileSuffixFilters?: Array<string>;
/**
* Maximum number of documents that can be selected.
* Value range: 1 to 500.
* Only the devices with the required system capability can select directories,
* and only one directory can be selected at a time.
* Default value: 1.
*
* @type { ?number }
* @syscap SystemCapability.FileManagement.UserFileService
* @since 10
*/
/**
* Maximum number of documents that can be selected.
* Value range: 1 to 500.
* Only the devices with the required system capability can select directories,
* and only one directory can be selected at a time.
* Default value: 1.
*
* @type { ?number }
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
maxSelectNumber?: number;
/**
* Selection mode. Only 2-in-1 devices are supported. The default value is FILE.
*
* @type { ?DocumentSelectMode }
* @syscap SystemCapability.FileManagement.UserFileService.FolderSelection
* @since 11
*/
/**
* Selection mode. Only 2-in-1 devices are supported. The default value is FILE.
*
* @type { ?DocumentSelectMode }
* @syscap SystemCapability.FileManagement.UserFileService.FolderSelection
* @crossplatform
* @atomicservice
* @since 12
*/
selectMode?: DocumentSelectMode;
/**
* Whether to start Picker.
* Default value: false.
* If authMode is true, defaultFilePathUri is mandatory, which specifies the URI of the file allowed to access.
*
* @type { ?boolean }
* @syscap SystemCapability.FileManagement.UserFileService.FolderSelection
* @atomicservice
* @since 12
*/
authMode?: boolean;
/**
* Whether to enable the batch authorization mode.
* The value false (default) means to disable the batch authorization mode;
* the value true means to enable the batch authorization mode.
* The multiUriArray parameter only takes effect when multAuthMode is set to true.
* Only mobile phones are supported.
*
* @type { ?boolean }
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 15
*/
multiAuthMode?: boolean;
/**
* Whether to pass the URIs for batch authorization (only files are supported).
* This parameter is used with multAuthMode, and does not take effect when multAuthMode is set to false.
* By default, this parameter is left empty.(The files displayed on the batch authorization page are empty.)
* Only mobile phones are supported.
*
* @type { ?Array<string> }
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 15
*/
multiUriArray?: Array<string>;
/**
* Whether to enable the aggregation view mode for a file management application.
* The default value is DEFAULT, indicating that this parameter does not take effect and the aggregation view is disabled.
* If this parameter is set to a value other than DEFAULT, other parameters do not take effect.
* Only mobile phones are supported.
*
* @type { ?MergeTypeMode }
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 15
*/
mergeMode?: MergeTypeMode;
/**
* Whether to support encryption (only files are supported).
* The default value is false.
* If this parameter is set to true, the picker will display a button that allows the user,
* files can be encrypted on the Picker page.
*
* @type { ?boolean }
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 19
*/
isEncryptionSupported?: boolean;
/**
* Theme color
*
* @type { ?CustomColors }
* @syscap SystemCapability.FileManagement.UserFileService
* @systemapi
* @since 18
*/
themeColor?: CustomColors;
}
/**
* Defines the options for saving documents.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Defines the options for saving documents.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
class DocumentSaveOptions {
/**
* Name of the document to save.
* If this parameter is not specified, the user needs to enter the the document name.
*
* @type { ?Array<string> }
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Name of the document to save.
* If this parameter is not specified, the user needs to enter the the document name.
*
* @type { ?Array<string> }
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
newFileNames?: Array<string>;
/**
* Path of the document or directory to save.
*
* @type { ?string }
* @syscap SystemCapability.FileManagement.UserFileService
* @since 10
*/
/**
* Path of the document or directory to save.
*
* @type { ?string }
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
defaultFilePathUri?: string;
/**
* Document suffix of the document to save. The value is a string array.
* Each element specifies an option, which includes at most two parts with a vertical bar (|) in between.
* The first part is the description, and the second part is the document suffix.
* If there is no "|", the option does not have the description. By default, all documents are saved.
*
* @type { ?Array<string> }
* @syscap SystemCapability.FileManagement.UserFileService
* @since 10
*/
/**
* Document suffix of the document to save. The value is a string array.
* Each element specifies an option, which includes at most two parts with a vertical bar (|) in between.
* The first part is the description, and the second part is the document suffix.
* If there is no "|", the option does not have the description. By default, all documents are saved.
*
* @type { ?Array<string> }
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 12
*/
fileSuffixChoices?: Array<string>;
/**
* Mode for starting Picker. Default value: DEFAULT.
* If pickerMode is DOWNLOAD,
* the settings of newFileNames, defaultFilePathUri, and fileSuffixChoices do not take effect.
*
* @type { ?DocumentPickerMode }
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 12
*/
pickerMode?: DocumentPickerMode;
/**
* Theme color
*
* @type { ?CustomColors }
* @syscap SystemCapability.FileManagement.UserFileService
* @systemapi
* @since 18
*/
themeColor?: CustomColors;
}
/**
* Provides APIs for selecting and saving documents in different formats.
* Before using the APIs of DocumentViewPicker, you need to create a DocumentViewPicker instance.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Provides APIs for selecting and saving documents in different formats.
* Before using the APIs of DocumentViewPicker, you need to create a DocumentViewPicker instance.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
class DocumentViewPicker {
/**
* A constructor used to create a DocumentViewPicker instance.
* This constructor is not recommended due to the potential risk of operation failure.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 12
*/
constructor();
/**
* A constructor used to create a DocumentViewPicker instance.
* This constructor is recommended. For details about how to obtain the context, see getHostContext.
*
* @param { Context } context - Application context (only UIAbilityContext is supported).
* For details about the application context of the stage model, see Context.
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 12
*/
constructor(context: Context);
/**
* A constructor used to create a DocumentViewPicker object in a window created by an application.
* In other scenarios, you are advised to use constructor(context: Context) to create a DocumentViewPicker object.
*
* @param { Context } context - Application context (only UIAbilityContext is supported).
* For details about the application context of the stage model, see Context.
* @param { window.Window } window - Window instance created by the application.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 13
*/
constructor(context: Context, window: window.Window);
/**
* Starts a documentPicker page for the user to select one or more documents.
* This API uses a promise to return the result.
* You can pass in DocumentSelectOptions to specify the URIs of the documents to select.
*
* @param { DocumentSelectOptions } option - Options for selecting documents.
* If this parameter is not specified, the documentPicker page is displayed by default.
* @returns { Promise<Array<string>> } Promise used to return the URIs of the documents selected.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Starts a documentPicker page for the user to select one or more documents.
* This API uses a promise to return the result.
* You can pass in DocumentSelectOptions to specify the URIs of the documents to select.
*
* @param { DocumentSelectOptions } option - Options for selecting documents.
* If this parameter is not specified, the documentPicker page is displayed by default.
* @returns { Promise<Array<string>> } Promise used to return the URIs of the documents selected.
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
select(option?: DocumentSelectOptions): Promise<Array<string>>;
/**
* Starts a documentPicker page for the user to select one or more documents.
* This API uses an asynchronous callback to return the result.
* You can pass in DocumentSelectOptions to specify the URIs of the documents to select.
*
* @param { DocumentSelectOptions } option - Options for selecting documents.
* @param { AsyncCallback<Array<string>> } callback - Callback invoked to return the URIs of the documents selected.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Starts a documentPicker page for the user to select one or more documents.
* This API uses an asynchronous callback to return the result.
* You can pass in DocumentSelectOptions to specify the URIs of the documents to select.
*
* @param { DocumentSelectOptions } option - Options for selecting documents.
* @param { AsyncCallback<Array<string>> } callback - Callback invoked to return the URIs of the documents selected.
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
select(option: DocumentSelectOptions, callback: AsyncCallback<Array<string>>): void;
/**
* Starts a documentPicker page for the user to select one or more documents.
* This API uses an asynchronous callback to return the URIs of the documents selected.
*
* @param { AsyncCallback<Array<string>> } callback - Callback invoked to return the URIs of the documents selected.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Starts a documentPicker page for the user to select one or more documents.
* This API uses an asynchronous callback to return the URIs of the documents selected.
*
* @param { AsyncCallback<Array<string>> } callback - Callback invoked to return the URIs of the documents selected.
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
select(callback: AsyncCallback<Array<string>>): void;
/**
* Starts a documentPicker page for the user to save one or more documents.
* This API uses a promise to return the result.
* You can pass in DocumentSaveOptions to specify the URIs of the documents to save.
*
* @param { DocumentSaveOptions } option - Options for saving the documents. If this parameter is not specified,
* a documentPicker page will be displayed for the user to enter the names of the documents to save.
* @returns { Promise<Array<string>> } Promise used to return the URIs of the documents saved.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Starts a documentPicker page for the user to save one or more documents.
* This API uses a promise to return the result.
* You can pass in DocumentSaveOptions to specify the URIs of the documents to save.
*
* @param { DocumentSaveOptions } option - Options for saving the documents. If this parameter is not specified,
* a documentPicker page will be displayed for the user to enter the names of the documents to save.
* @returns { Promise<Array<string>> } Promise used to return the URIs of the documents saved.
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
save(option?: DocumentSaveOptions): Promise<Array<string>>;
/**
* Starts a documentPicker page for the user to save one or more documents.
* This API uses an asynchronous callback to return the result.
* You can pass in DocumentSaveOptions to specify the URIs of the documents to save.
*
* @param { DocumentSaveOptions } option - Options for saving the documents.
* @param { AsyncCallback<Array<string>> } callback - Callback invoked to return the URIs of the documents saved.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Starts a documentPicker page for the user to save one or more documents.
* This API uses an asynchronous callback to return the result.
* You can pass in DocumentSaveOptions to specify the URIs of the documents to save.
*
* @param { DocumentSaveOptions } option - Options for saving the documents.
* @param { AsyncCallback<Array<string>> } callback - Callback invoked to return the URIs of the documents saved.
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
save(option: DocumentSaveOptions, callback: AsyncCallback<Array<string>>): void;
/**
* Starts a documentPicker page for the user to save one or more documents.
* This API uses an asynchronous callback to return the URIs of the documents to save.
*
* @param { AsyncCallback<Array<string>> } callback - Callback invoked to return the URIs of the documents saved.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Starts a documentPicker page for the user to save one or more documents.
* This API uses an asynchronous callback to return the URIs of the documents to save.
*
* @param { AsyncCallback<Array<string>> } callback - Callback invoked to return the URIs of the documents saved.
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
save(callback: AsyncCallback<Array<string>>): void;
/**
* Obtains the index of the file suffix type of the file saved.
* Only 2-in-1 devices are supported.
* This method takes effect only when used with save().
* This method can be used only after DocumentSaveOptions.
* fileSuffixChoices is configured.
* The index (number) returned by this method indicates the location of
* the file suffix specified in DocumentSaveOptions.fileSuffixChoices.
* If no file suffix is specified, getSelectedIndex() returns -1.
*
* @returns { number } Returns the index of the suffix array fileSuffixChoices configured by the user in DocumentSaveOptions.
* @syscap SystemCapability.FileManagement.UserFileService.FolderSelection
* @crossplatform
* @atomicservice
* @since 14
*/
getSelectedIndex(): number;
}
/**
* Defines the options for selecting audio clips.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Defines the options for selecting audio clips.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
class AudioSelectOptions {
/**
* Maximum number of audio clips that can be selected.
* Default value: 1. Value range: 1 to 500
*
* @type { ?number }
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
maxSelectNumber?: number;
}
/**
* Defines the options for saving audio clips.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Defines the options for saving audio clips.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
class AudioSaveOptions {
/**
* File names of the audio clips to save.
* If this parameter is not specified, the user needs to enter the file names.
*
* @type { ?Array<string> }
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* File names of the audio clips to save.
* If this parameter is not specified, the user needs to enter the file names.
*
* @type { ?Array<string> }
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
newFileNames?: Array<string>;
}
/**
* Provides APIs for selecting and saving audio clips.
* Before using the APIs of AudioViewPicker, you need to create an AudioViewPicker instance.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Provides APIs for selecting and saving audio clips.
* Before using the APIs of AudioViewPicker, you need to create an AudioViewPicker instance.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
class AudioViewPicker {
/**
* A constructor used to create an AudioViewPicker instance.
* This constructor is not recommended due to the potential risk of operation failure.
*
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 12
*/
constructor();
/**
* A constructor used to create an AudioViewPicker instance.
* This constructor is recommended. For details about how to obtain the context, see getHostContext.
*
* @param { Context } context - Application context (only UIAbilityContext is supported).
* For details about the application context of the stage model, see Context.
* @syscap SystemCapability.FileManagement.UserFileService
* @atomicservice
* @since 12
*/
constructor(context: Context);
/**
* Starts an audioPicker page for the user to select one or more audio clips.
* This API uses a promise to return the result.
* You can pass in AudioSelectOptions to specify the URIs of the audio clips to select.
*
* @param { AudioSelectOptions } option - Options for selecting audio clips.
* If this parameter is not specified, the audioPicker page is displayed by default.
* @returns { Promise<Array<string>> } Promise used to return the URIs of the audio clips selected.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Starts an audioPicker page for the user to select one or more audio clips.
* This API uses a promise to return the result.
* You can pass in AudioSelectOptions to specify the URIs of the audio clips to select.
*
* @param { AudioSelectOptions } option - Options for selecting audio clips.
* If this parameter is not specified, the audioPicker page is displayed by default.
* @returns { Promise<Array<string>> } Promise used to return the URIs of the audio clips selected.
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
select(option?: AudioSelectOptions): Promise<Array<string>>;
/**
* Starts an audioPicker page for the user to select one or more audio clips.
* This API uses an asynchronous callback to return the result.
* You can pass in AudioSelectOptions to specify the URIs of the audio clips to select.
*
* @param { AudioSelectOptions } option - Options for selecting audio clips.
* @param { AsyncCallback<Array<string>> } callback - Callback invoked to return the URIs of the audio clips selected.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Starts an audioPicker page for the user to select one or more audio clips.
* This API uses an asynchronous callback to return the result.
* You can pass in AudioSelectOptions to specify the URIs of the audio clips to select.
*
* @param { AudioSelectOptions } option - Options for selecting audio clips.
* @param { AsyncCallback<Array<string>> } callback - Callback invoked to return the URIs of the audio clips selected.
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @since 12
*/
select(option: AudioSelectOptions, callback: AsyncCallback<Array<string>>): void;
/**
* Starts an audioPicker page for the user to select one or more audio clips.
* This API uses an asynchronous callback to return the URIs of the audio clips selected.
*
* @param { AsyncCallback<Array<string>> } callback - Callback invoked to return the URIs of the audio clips selected.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Starts an audioPicker page for the user to select one or more audio clips.
* This API uses an asynchronous callback to return the URIs of the audio clips selected.
*
* @param { AsyncCallback<Array<string>> } callback - Callback invoked to return the URIs of the audio clips selected.
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @since 12
*/
select(callback: AsyncCallback<Array<string>>): void;
/**
* Starts an audioPicker page (currently, a documentPicker page is displayed)
* for the user to save one or more audio clips.
* This API uses a promise to return the result.
* You can pass in AudioSaveOptions to specify the URIs of the audio clips to save.
*
* @param { AudioSaveOptions } option - Options for saving audio clips.If this parameter is not specified,
* an audioPicker page will be displayed for the user to enter the names of the files to save.
* @returns { Promise<Array<string>> } Promise used to return the URIs of the audio clips saved.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Starts an audioPicker page (currently, a documentPicker page is displayed)
* for the user to save one or more audio clips.
* This API uses a promise to return the result.
* You can pass in AudioSaveOptions to specify the URIs of the audio clips to save.
*
* @param { AudioSaveOptions } option - Options for saving audio clips.If this parameter is not specified,
* an audioPicker page will be displayed for the user to enter the names of the files to save.
* @returns { Promise<Array<string>> } Promise used to return the URIs of the audio clips saved.
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @atomicservice
* @since 12
*/
save(option?: AudioSaveOptions): Promise<Array<string>>;
/**
* Starts an audioPicker page (currently, a documentPicker page is displayed)
* for the user to save one or more audio clips.
* This API uses an asynchronous callback to return the result.
* You can pass in AudioSaveOptions to specify the URIs of the audio clips to save.
*
* @param { AudioSaveOptions } option - Options for saving audio clips.
* @param { AsyncCallback<Array<string>> } callback - Callback invoked to return the URIs of the audio clips saved.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Starts an audioPicker page (currently, a documentPicker page is displayed)
* for the user to save one or more audio clips.
* This API uses an asynchronous callback to return the result.
* You can pass in AudioSaveOptions to specify the URIs of the audio clips to save.
*
* @param { AudioSaveOptions } option -Options for saving audio clips.
* @param { AsyncCallback<Array<string>> } callback - Callback invoked to return the URIs of the audio clips saved.
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @since 12
*/
save(option: AudioSaveOptions, callback: AsyncCallback<Array<string>>): void;
/**
* Starts an audioPicker page (currently, a documentPicker page is displayed)
* for the user to save one or more audio clips.
* This API uses an asynchronous callback to return the URIs of the audio clips saved.
*
* @param { AsyncCallback<Array<string>> } callback - Callback invoked to return the URIs of the audio clips saved.
* @syscap SystemCapability.FileManagement.UserFileService
* @since 9
*/
/**
* Starts an audioPicker page (currently, a documentPicker page is displayed)
* for the user to save one or more audio clips.
* This API uses an asynchronous callback to return the URIs of the audio clips saved.
*
* @param { AsyncCallback<Array<string>> } callback - Callback invoked to return the URIs of the audio clips saved.
* @syscap SystemCapability.FileManagement.UserFileService
* @crossplatform
* @since 12
*/
save(callback: AsyncCallback<Array<string>>): void;
}
}
export default picker;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openharmony/interface_sdk-js.git
git@gitee.com:openharmony/interface_sdk-js.git
openharmony
interface_sdk-js
interface_sdk-js
master

搜索帮助