diff --git a/api/@ohos.request.d.ts b/api/@ohos.request.d.ts index 71240158bb72cd220439e3d82c371fb77999cdbb..78e4d55f6c2bfbf3fc5bb0f3ecdf872a4777340f 100644 --- a/api/@ohos.request.d.ts +++ b/api/@ohos.request.d.ts @@ -23,6 +23,55 @@ import BaseContext from './application/BaseContext'; * @permission ohos.permission.INTERNET */ declare namespace request { + /** + * the permissions check fails + * @errorcode 13400201 + * @syscap SystemCapability.MiscServices.Download + * @since 9 + */ + const EXCEPTION_PERMISSION: number; + /** + * the parameters check fails + * @errorcode 13400401 + * @syscap SystemCapability.MiscServices.Download + * @since 9 + */ + const EXCEPTION_PARAMCHECK: number; + /** + * call unsupported api + * @errorcode 13400801 + * @syscap SystemCapability.MiscServices.Download + * @since 9 + */ + const EXCEPTION_UNSUPPORTED: number; + /** + * file operation error + * @errorcode 13400001 + * @syscap SystemCapability.MiscServices.Download + * @since 9 + */ + const EXCEPTION_FILEIO: number; + /** + * bad file path + * @errorcode 13400002 + * @syscap SystemCapability.MiscServices.Download + * @since 9 + */ + const EXCEPTION_FILEPATH: number; + /** + * task manager service error + * @errorcode 13400003 + * @syscap SystemCapability.MiscServices.Download + * @since 9 + */ + const EXCEPTION_SERVICE: number; + /** + * others error + * @errorcode 13499999 + * @syscap SystemCapability.MiscServices.Download + * @since 9 + */ + const EXCEPTION_OTHERS: number; /** * Bit flag indicating download is allowed when using the cellular network. @@ -112,6 +161,22 @@ declare namespace request { */ const ERROR_UNKNOWN: number; + /** + * Indicates network offline. + * @syscap SystemCapability.MiscServices.Download + * @since 9 + * @permission ohos.permission.INTERNET + */ + const ERROR_OFFLINE: number; + + /** + * Indicates network type configuration error. + * @syscap SystemCapability.MiscServices.Download + * @since 9 + * @permission ohos.permission.INTERNET + */ + const ERROR_UNSUPPORTED_NETWORK_TYPE: number; + /** * Indicates that the download is paused and waiting for a WLAN connection, because the file size exceeds the maximum allowed for a session using the cellular network. * @syscap SystemCapability.MiscServices.Download @@ -188,6 +253,7 @@ declare namespace request { * Starts a download session. * @syscap SystemCapability.MiscServices.Download * @since 6 + * @deprecated since 9, use 'downloadFile' instead. * @param config download config * @param callback Indicate the callback function to receive DownloadTask. * @permission ohos.permission.INTERNET @@ -204,14 +270,21 @@ declare namespace request { * @param config download config * @param callback Indicate the callback function to receive DownloadTask. * @permission ohos.permission.INTERNET + * @throws {BusinessError} if exception occurs + * @errorcode EXCEPTION_PERMISSION + * @errorcode EXCEPTION_PARAMCHECK + * @errorcode EXCEPTION_FILEIO + * @errorcode EXCEPTION_FILEPATH + * @errorcode EXCEPTION_SERVICE * @return - */ - function download(context: BaseContext, config: DownloadConfig, callback: AsyncCallback): void; + function downloadFile(context: BaseContext, config: DownloadConfig, callback: AsyncCallback): void; /** * Starts a download session. * @syscap SystemCapability.MiscServices.Download * @since 6 + * @deprecated since 9, use 'downloadFile' instead. * @param config download config * @permission ohos.permission.INTERNET * @return - @@ -226,14 +299,21 @@ declare namespace request { * @param BaseContext Indicates the application BaseContext. * @param config download config * @permission ohos.permission.INTERNET + * @throws {BusinessError} if exception occurs + * @errorcode EXCEPTION_PERMISSION + * @errorcode EXCEPTION_PARAMCHECK + * @errorcode EXCEPTION_FILEIO + * @errorcode EXCEPTION_FILEPATH + * @errorcode EXCEPTION_SERVICE * @return - */ - function download(context: BaseContext, config: DownloadConfig): Promise; + function downloadFile(context: BaseContext, config: DownloadConfig): Promise; /** * Starts a upload session. * @syscap SystemCapability.MiscServices.Upload * @since 6 + * @deprecated since 9, use 'uploadFile' instead. * @param config upload config * @param callback Indicate the callback function to receive UploadTask. * @permission ohos.permission.INTERNET @@ -250,14 +330,19 @@ declare namespace request { * @param config upload config * @param callback Indicate the callback function to receive UploadTask. * @permission ohos.permission.INTERNET + * @throws {BusinessError} if exception occurs + * @errorcode EXCEPTION_PERMISSION + * @errorcode EXCEPTION_PARAMCHECK + * @errorcode EXCEPTION_FILEPATH * @return - */ - function upload(context: BaseContext, config: UploadConfig, callback: AsyncCallback): void; + function uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback): void; /** * Starts a upload session. * @syscap SystemCapability.MiscServices.Upload * @since 6 + * @deprecated since 9, use 'uploadFile' instead. * @param config upload config * @permission ohos.permission.INTERNET * @return - @@ -272,9 +357,13 @@ declare namespace request { * @param BaseContext Indicates the application BaseContext. * @param config upload config * @permission ohos.permission.INTERNET + * @throws {BusinessError} if exception occurs + * @errorcode EXCEPTION_PERMISSION + * @errorcode EXCEPTION_PARAMCHECK + * @errorcode EXCEPTION_FILEPATH * @return - */ - function upload(context: BaseContext, config: UploadConfig): Promise; + function uploadFile(context: BaseContext, config: UploadConfig): Promise; /** * DownloadConfig data Structure @@ -520,6 +609,7 @@ declare namespace request { * Deletes a download session and the downloaded files. * @syscap SystemCapability.MiscServices.Download * @since 6 + * @deprecated since 9, use 'delete' instead. * @param callback Indicates asynchronous invoking Result. * @permission ohos.permission.INTERNET * @return - @@ -530,6 +620,7 @@ declare namespace request { * Deletes a download session and the downloaded files. * @syscap SystemCapability.MiscServices.Download * @since 6 + * @deprecated since 9, use 'delete' instead. * @permission ohos.permission.INTERNET * @return - */ @@ -539,6 +630,7 @@ declare namespace request { * Pause a download session. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9, use 'suspend' instead. * @param callback Indicates asynchronous invoking Result. * @permission ohos.permission.INTERNET * @return - @@ -549,6 +641,7 @@ declare namespace request { * Pause a download session. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9, use 'suspend' instead. * @permission ohos.permission.INTERNET * @return - */ @@ -558,6 +651,7 @@ declare namespace request { * Resume a paused download session. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9, use 'restore' instead. * @param callback Indicates asynchronous invoking Result. * @permission ohos.permission.INTERNET * @return - @@ -568,6 +662,7 @@ declare namespace request { * Resume a paused download session. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9, use 'restore' instead. * @permission ohos.permission.INTERNET * @return - */ @@ -577,6 +672,7 @@ declare namespace request { * Queries download information of a session, which is defined in DownloadSession.DownloadInfo. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9, use 'getTaskInfo' instead. * @param callback Indicate the callback function to receive download info. * @permission ohos.permission.INTERNET * @return - @@ -587,6 +683,7 @@ declare namespace request { * Queries download information of a session, which is defined in DownloadSession.DownloadInfo. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9, use 'getTaskInfo' instead. * @permission ohos.permission.INTERNET * @return - */ @@ -596,6 +693,7 @@ declare namespace request { * Queries the MIME type of the download file. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9, use 'getTaskMimeType' instead. * @param callback Indicate the callback function to receive download file MIME type. * @permission ohos.permission.INTERNET * @return - @@ -606,10 +704,81 @@ declare namespace request { * Queries the MIME type of the download file. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9, use 'getTaskMimeType' instead. * @permission ohos.permission.INTERNET * @return - */ queryMimeType(): Promise; + + /** + * Delete the download task + * @since 9 + * @permission ohos.permission.INTERNET + * @throws {BusinessError} if exception occurs + * @errorcode EXCEPTION_PERMISSION + * @errorcode EXCEPTION_PARAMCHECK + * @errorcode EXCEPTION_DATABASE + * @errorcode EXCEPTION_SERVICE + * @syscap SystemCapability.MiscServices.Download + */ + delete(callback: AsyncCallback): void; + delete(): Promise; + + /** + * Suspend the download task + * @since 9 + * @permission ohos.permission.INTERNET + * @throws {BusinessError} if exception occurs + * @errorcode EXCEPTION_PERMISSION + * @errorcode EXCEPTION_PARAMCHECK + * @errorcode EXCEPTION_DATABASE + * @errorcode EXCEPTION_SERVICE + * @syscap SystemCapability.MiscServices.Download + */ + suspend(callback: AsyncCallback): void; + suspend(): Promise; + + /** + * Restore the download task + * @since 9 + * @permission ohos.permission.INTERNET + * @throws {BusinessError} if exception occurs + * @errorcode EXCEPTION_PERMISSION + * @errorcode EXCEPTION_PARAMCHECK + * @errorcode EXCEPTION_DATABASE + * @errorcode EXCEPTION_SERVICE + * @syscap SystemCapability.MiscServices.Download + */ + restore(callback: AsyncCallback): void; + restore(): Promise; + + /** + * Get the download task info + * @since 9 + * @permission ohos.permission.INTERNET + * @throws {BusinessError} if exception occurs + * @errorcode EXCEPTION_PERMISSION + * @errorcode EXCEPTION_PARAMCHECK + * @errorcode EXCEPTION_DATABASE + * @errorcode EXCEPTION_SERVICE + * @syscap SystemCapability.MiscServices.Download + */ + getTaskInfo(callback: AsyncCallback): void; + getTaskInfo(): Promise; + + /** + * Get mimetype of the download task + * @since 9 + * @permission ohos.permission.INTERNET + * @throws {BusinessError} if exception occurs + * @errorcode EXCEPTION_PERMISSION + * @errorcode EXCEPTION_PARAMCHECK + * @errorcode EXCEPTION_DATABASE + * @errorcode EXCEPTION_SERVICE + * @syscap SystemCapability.MiscServices.Download + */ + getTaskMimeType(callback: AsyncCallback): void; + getTaskMimeType(): Promise; } /** @@ -831,9 +1000,10 @@ declare namespace request { off(type:'complete' | 'fail', callback?: Callback>): void; /** - * Deletes a upload session. + * Remove a upload session. * @syscap SystemCapability.MiscServices.Upload * @since 6 + * @deprecated since 9, use 'delete' instead. * @param callback Indicates asynchronous invoking Result. * @permission ohos.permission.INTERNET * @return - @@ -841,15 +1011,41 @@ declare namespace request { remove(callback: AsyncCallback): void; /** - * Deletes a upload session. + * Remove a upload session. * @syscap SystemCapability.MiscServices.Upload * @since 6 + * @deprecated since 9, use 'delete' instead. * @permission ohos.permission.INTERNET * @return - */ remove(): Promise; + + /** + * Delete the upload task + * @since 9 + * @permission ohos.permission.INTERNET + * @throws {BusinessError} if exception occurs + * @errorcode EXCEPTION_PERMISSION + * @errorcode EXCEPTION_PARAMCHECK + * @errorcode EXCEPTION_DATABASE + * @errorcode EXCEPTION_SERVICE + * @syscap SystemCapability.MiscServices.Upload + */ + delete(callback: AsyncCallback): void; + + /** + * Delete the upload task + * @since 9 + * @permission ohos.permission.INTERNET + * @throws {BusinessError} if exception occurs + * @errorcode EXCEPTION_PERMISSION + * @errorcode EXCEPTION_PARAMCHECK + * @errorcode EXCEPTION_DATABASE + * @errorcode EXCEPTION_SERVICE + * @syscap SystemCapability.MiscServices.Upload + */ + delete(): Promise; } } export default request; - diff --git a/api/@system.request.d.ts b/api/@system.request.d.ts index 9c946b7d73f0906f1460a6a933dd0b729c174bf4..27c2a23aba04a4211d76484afc2724d4fca3d65a 100644 --- a/api/@system.request.d.ts +++ b/api/@system.request.d.ts @@ -15,12 +15,14 @@ /** * @syscap SystemCapability.MiscServices.Upload + * @deprecated since 9, use '@ohos.request' instead. */ export interface UploadResponse { /** * Status code returned by the server. * @syscap SystemCapability.MiscServices.Upload * @since 3 + * @deprecated since 9 */ code: number; @@ -29,6 +31,7 @@ export interface UploadResponse { * The value type is determined by the returned content. * @syscap SystemCapability.MiscServices.Upload * @since 3 + * @deprecated since 9 */ data: string; @@ -36,42 +39,49 @@ export interface UploadResponse { * Headers returned by the server. * @syscap SystemCapability.MiscServices.Upload * @since 3 + * @deprecated since 9 */ headers: Object; } /** * @syscap SystemCapability.MiscServices.Download + * @deprecated since 9 */ export interface DownloadResponse { /** * Download token, which is used to obtain the download status. * @syscap SystemCapability.MiscServices.Download * @since 3 + * @deprecated since 9 */ token: string; } /** * @syscap SystemCapability.MiscServices.Download + * @deprecated since 9 */ export interface OnDownloadCompleteResponse { /** * URI of the download file. * @syscap SystemCapability.MiscServices.Download * @since 3 + * @deprecated since 9 */ uri: string; } /** * @syscap SystemCapability.MiscServices.Upload + * @deprecated since 9 */ export interface RequestFile { /** * File name in the header when multipart is used. * @syscap SystemCapability.MiscServices.Upload * @since 3 + * @deprecated since 9 */ filename?: string; @@ -79,6 +89,7 @@ export interface RequestFile { * Name of a form item when multipart is used. The default value is file. * @syscap SystemCapability.MiscServices.Upload * @since 3 + * @deprecated since 9 */ name?: string; @@ -86,6 +97,7 @@ export interface RequestFile { * Local storage directory of a file. * @syscap SystemCapability.MiscServices.Upload * @since 3 + * @deprecated since 9 */ uri: string; @@ -94,18 +106,21 @@ export interface RequestFile { * By default, the type is obtained based on the suffix of the file name or URI. * @syscap SystemCapability.MiscServices.Upload * @since 3 + * @deprecated since 9 */ type?: string; } /** * @syscap SystemCapability.MiscServices.Upload + * @deprecated since 9 */ export interface RequestData { /** * Name of the form element. * @syscap SystemCapability.MiscServices.Upload * @since 3 + * @deprecated since 9 */ name: string; @@ -113,18 +128,21 @@ export interface RequestData { * Value of the form element. * @syscap SystemCapability.MiscServices.Upload * @since 3 + * @deprecated since 9 */ value: string; } /** * @syscap SystemCapability.MiscServices.Upload + * @deprecated since 9 */ export interface UploadRequestOptions { /** * Resource URL. * @syscap SystemCapability.MiscServices.Upload * @since 3 + * @deprecated since 9 */ url: string; @@ -132,6 +150,7 @@ export interface UploadRequestOptions { * Form data in the request body. * @syscap SystemCapability.MiscServices.Upload * @since 3 + * @deprecated since 9 */ data?: Array; @@ -139,6 +158,7 @@ export interface UploadRequestOptions { * List of files to upload, which is submitted through multipart/form-data. * @syscap SystemCapability.MiscServices.Upload * @since 3 + * @deprecated since 9 */ files: Array; @@ -146,6 +166,7 @@ export interface UploadRequestOptions { * Request header. * @syscap SystemCapability.MiscServices.Upload * @since 3 + * @deprecated since 9 */ header?: Object; @@ -153,6 +174,7 @@ export interface UploadRequestOptions { * Request methods available: POST and PUT. The default value is POST. * @syscap SystemCapability.MiscServices.Upload * @since 3 + * @deprecated since 9 */ method?: string; @@ -160,6 +182,7 @@ export interface UploadRequestOptions { * Called when the files are uploaded successfully. * @syscap SystemCapability.MiscServices.Upload * @since 3 + * @deprecated since 9 */ success?: (data: UploadResponse) => void; @@ -167,6 +190,7 @@ export interface UploadRequestOptions { * Called when uploading fails. * @syscap SystemCapability.MiscServices.Upload * @since 3 + * @deprecated since 9 */ fail?: (data: any, code: number) => void; @@ -174,18 +198,21 @@ export interface UploadRequestOptions { * Called when the execution is completed. * @syscap SystemCapability.MiscServices.Upload * @since 3 + * @deprecated since 9 */ complete?: () => void; } /** * @syscap SystemCapability.MiscServices.Download + * @deprecated since 9 */ export interface DownloadRequestOptions { /** * Resource URL. * @syscap SystemCapability.MiscServices.Download * @since 3 + * @deprecated since 9 */ url: string; @@ -194,6 +221,7 @@ export interface DownloadRequestOptions { * The value is obtained from the current request or resource URL by default. * @syscap SystemCapability.MiscServices.Download * @since 3 + * @deprecated since 9 */ filename?: string; @@ -201,6 +229,7 @@ export interface DownloadRequestOptions { * Request header. * @syscap SystemCapability.MiscServices.Download * @since 3 + * @deprecated since 9 */ header?: string; @@ -209,6 +238,7 @@ export interface DownloadRequestOptions { * The default value is the file name. * @syscap SystemCapability.MiscServices.Download * @since 3 + * @deprecated since 9 */ description?: string; @@ -216,6 +246,7 @@ export interface DownloadRequestOptions { * Called when the files are successfully downloaded. * @syscap SystemCapability.MiscServices.Download * @since 3 + * @deprecated since 9 */ success?: (data: DownloadResponse) => void; @@ -223,6 +254,7 @@ export interface DownloadRequestOptions { * Called when downloading fails. * @syscap SystemCapability.MiscServices.Download * @since 3 + * @deprecated since 9 */ fail?: (data: any, code: number) => void; @@ -230,18 +262,21 @@ export interface DownloadRequestOptions { * Called when the execution is completed. * @syscap SystemCapability.MiscServices.Download * @since 3 + * @deprecated since 9 */ complete?: () => void; } /** * @syscap SystemCapability.MiscServices.Download + * @deprecated since 9 */ export interface OnDownloadCompleteOptions { /** * Token of the result returned by the download function. * @syscap SystemCapability.MiscServices.Download * @since 3 + * @deprecated since 9 */ token: string; @@ -249,6 +284,7 @@ export interface OnDownloadCompleteOptions { * Called when the downloads are successfully obtained * @syscap SystemCapability.MiscServices.Download * @since 3 + * @deprecated since 9 */ success?: (data: OnDownloadCompleteResponse) => void; @@ -256,6 +292,7 @@ export interface OnDownloadCompleteOptions { * Called when the downloads fail to be obtained. * @syscap SystemCapability.MiscServices.Download * @since 3 + * @deprecated since 9 */ fail?: (data: any, code: number) => void; @@ -263,15 +300,20 @@ export interface OnDownloadCompleteOptions { * Called when the execution is completed. * @syscap SystemCapability.MiscServices.Download * @since 3 + * @deprecated since 9 */ complete?: () => void; } +/** + * @deprecated since 9 + */ export default class Request { /** * Upload files. * @param options Options. * @syscap SystemCapability.MiscServices.Upload + * @deprecated since 9 */ static upload(options: UploadRequestOptions): void; @@ -279,6 +321,7 @@ export default class Request { * This API is used to download files. * @param options Options. * @syscap SystemCapability.MiscServices.Download + * @deprecated since 9 */ static download(options: DownloadRequestOptions): void; @@ -286,6 +329,7 @@ export default class Request { * Listens to download task status. * @param options Options. * @syscap SystemCapability.MiscServices.Download + * @deprecated since 9 */ static onDownloadComplete(options: OnDownloadCompleteOptions): void; } \ No newline at end of file