From fd5473c2801273c5f1c2a09251f580f0a99fdb57 Mon Sep 17 00:00:00 2001 From: nagexiucai Date: Tue, 13 Sep 2022 17:09:13 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= =?UTF-8?q?=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nagexiucai --- api/@ohos.request.d.ts | 255 +++++++++++++++++++++++++++++++++++++-- api/@system.request.d.ts | 44 +++++++ 2 files changed, 292 insertions(+), 7 deletions(-) diff --git a/api/@ohos.request.d.ts b/api/@ohos.request.d.ts index 71240158bb..10d7cd3e60 100644 --- a/api/@ohos.request.d.ts +++ b/api/@ohos.request.d.ts @@ -23,6 +23,90 @@ 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; + /** + * http response status code is not ok + * @errorcode 13400001 + * @syscap SystemCapability.MiscServices.Download + * @since 9 + */ + const EXCEPTION_RESPONSE: number; + /** + * file operation error + * @errorcode 13400002 + * @syscap SystemCapability.MiscServices.Download + * @since 9 + */ + const EXCEPTION_FILEIO: number; + /** + * get/compute file size error + * @errorcode 13400003 + * @syscap SystemCapability.MiscServices.Download + * @since 9 + */ + const EXCEPTION_FILESIZE: number; + /** + * bad file path + * @errorcode 13400004 + * @syscap SystemCapability.MiscServices.Download + * @since 9 + */ + const EXCEPTION_FILEPATH: number; + /** + * task timeout + * @errorcode 13400005 + * @syscap SystemCapability.MiscServices.Download + * @since 9 + */ + const EXCEPTION_TASKTIMEOUT: number; + /** + * exceed task retries limit + * @errorcode 13400006 + * @syscap SystemCapability.MiscServices.Download + * @since 9 + */ + const EXCEPTION_TASKRETRIES: number; + /** + * da error + * @errorcode 13400007 + * @syscap SystemCapability.MiscServices.Download + * @since 9 + */ + const EXCEPTION_DATABASE: number; + /** + * sa error + * @errorcode 13400008 + * @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. @@ -44,6 +128,7 @@ declare namespace request { * Indicates that the download cannot be resumed for some temporary errors. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9 * @permission ohos.permission.INTERNET */ const ERROR_CANNOT_RESUME: number; @@ -52,6 +137,7 @@ declare namespace request { * Indicates that no storage device, such as an SD card, is found. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9 * @permission ohos.permission.INTERNET */ const ERROR_DEVICE_NOT_FOUND: number; @@ -60,6 +146,7 @@ declare namespace request { * Indicates that files to be downloaded already exist, and that the download session cannot overwrite the existing files. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9 * @permission ohos.permission.INTERNET */ const ERROR_FILE_ALREADY_EXISTS: number; @@ -68,6 +155,7 @@ declare namespace request { * Indicates that a file operation fails. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9 * @permission ohos.permission.INTERNET */ const ERROR_FILE_ERROR: number; @@ -76,6 +164,7 @@ declare namespace request { * Indicates that the HTTP transmission fails. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9 * @permission ohos.permission.INTERNET */ const ERROR_HTTP_DATA_ERROR: number; @@ -84,6 +173,7 @@ declare namespace request { * Indicates insufficient storage space. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9 * @permission ohos.permission.INTERNET */ const ERROR_INSUFFICIENT_SPACE: number; @@ -92,6 +182,7 @@ declare namespace request { * Indicates an error caused by too many network redirections. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9 * @permission ohos.permission.INTERNET */ const ERROR_TOO_MANY_REDIRECTS: number; @@ -100,6 +191,7 @@ declare namespace request { * Indicates an HTTP code that cannot be identified. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9 * @permission ohos.permission.INTERNET */ const ERROR_UNHANDLED_HTTP_CODE: number; @@ -108,6 +200,7 @@ declare namespace request { * Indicates an undefined error. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9 * @permission ohos.permission.INTERNET */ const ERROR_UNKNOWN: number; @@ -188,6 +281,7 @@ declare namespace request { * Starts a download session. * @syscap SystemCapability.MiscServices.Download * @since 6 + * @deprecated since 9 * @param config download config * @param callback Indicate the callback function to receive DownloadTask. * @permission ohos.permission.INTERNET @@ -204,14 +298,26 @@ 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_RESPONSE + * @errorcode EXCEPTION_FILEIO + * @errorcode EXCEPTION_FILESIZE + * @errorcode EXCEPTION_FILEPATH + * @errorcode EXCEPTION_TASKTIMEOUT + * @errorcode EXCEPTION_TASKRETRIES + * @errorcode EXCEPTION_DATABASE + * @errorcode EXCEPTION_SERVICE * @return - */ - function download(context: BaseContext, config: DownloadConfig, callback: AsyncCallback): void; + function downloadV9(context: BaseContext, config: DownloadConfig, callback: AsyncCallback): void; /** * Starts a download session. * @syscap SystemCapability.MiscServices.Download * @since 6 + * @deprecated since 9 * @param config download config * @permission ohos.permission.INTERNET * @return - @@ -226,14 +332,26 @@ 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_RESPONSE + * @errorcode EXCEPTION_FILEIO + * @errorcode EXCEPTION_FILESIZE + * @errorcode EXCEPTION_FILEPATH + * @errorcode EXCEPTION_TASKTIMEOUT + * @errorcode EXCEPTION_TASKRETRIES + * @errorcode EXCEPTION_DATABASE + * @errorcode EXCEPTION_SERVICE * @return - */ - function download(context: BaseContext, config: DownloadConfig): Promise; + function downloadV9(context: BaseContext, config: DownloadConfig): Promise; /** * Starts a upload session. * @syscap SystemCapability.MiscServices.Upload * @since 6 + * @deprecated since 9 * @param config upload config * @param callback Indicate the callback function to receive UploadTask. * @permission ohos.permission.INTERNET @@ -250,14 +368,22 @@ 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_RESPONSE + * @errorcode EXCEPTION_FILEIO + * @errorcode EXCEPTION_FILESIZE + * @errorcode EXCEPTION_FILEPATH * @return - */ - function upload(context: BaseContext, config: UploadConfig, callback: AsyncCallback): void; + function uploadV9(context: BaseContext, config: UploadConfig, callback: AsyncCallback): void; /** * Starts a upload session. * @syscap SystemCapability.MiscServices.Upload * @since 6 + * @deprecated since 9 * @param config upload config * @permission ohos.permission.INTERNET * @return - @@ -272,9 +398,16 @@ 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_RESPONSE + * @errorcode EXCEPTION_FILEIO + * @errorcode EXCEPTION_FILESIZE + * @errorcode EXCEPTION_FILEPATH * @return - */ - function upload(context: BaseContext, config: UploadConfig): Promise; + function uploadV9(context: BaseContext, config: UploadConfig): Promise; /** * DownloadConfig data Structure @@ -520,6 +653,7 @@ declare namespace request { * Deletes a download session and the downloaded files. * @syscap SystemCapability.MiscServices.Download * @since 6 + * @deprecated since 9 * @param callback Indicates asynchronous invoking Result. * @permission ohos.permission.INTERNET * @return - @@ -530,6 +664,7 @@ declare namespace request { * Deletes a download session and the downloaded files. * @syscap SystemCapability.MiscServices.Download * @since 6 + * @deprecated since 9 * @permission ohos.permission.INTERNET * @return - */ @@ -539,6 +674,7 @@ declare namespace request { * Pause a download session. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9 * @param callback Indicates asynchronous invoking Result. * @permission ohos.permission.INTERNET * @return - @@ -549,6 +685,7 @@ declare namespace request { * Pause a download session. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9 * @permission ohos.permission.INTERNET * @return - */ @@ -558,6 +695,7 @@ declare namespace request { * Resume a paused download session. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9 * @param callback Indicates asynchronous invoking Result. * @permission ohos.permission.INTERNET * @return - @@ -568,6 +706,7 @@ declare namespace request { * Resume a paused download session. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9 * @permission ohos.permission.INTERNET * @return - */ @@ -577,6 +716,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 * @param callback Indicate the callback function to receive download info. * @permission ohos.permission.INTERNET * @return - @@ -587,6 +727,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 * @permission ohos.permission.INTERNET * @return - */ @@ -596,6 +737,7 @@ declare namespace request { * Queries the MIME type of the download file. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9 * @param callback Indicate the callback function to receive download file MIME type. * @permission ohos.permission.INTERNET * @return - @@ -606,10 +748,81 @@ declare namespace request { * Queries the MIME type of the download file. * @syscap SystemCapability.MiscServices.Download * @since 7 + * @deprecated since 9 * @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(callback: AsyncCallback): void; } /** @@ -673,7 +886,7 @@ declare namespace request { * @since 6 * @permission ohos.permission.INTERNET */ - value: string; + value: string|ArrayBuffer; } /** @@ -831,9 +1044,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 * @param callback Indicates asynchronous invoking Result. * @permission ohos.permission.INTERNET * @return - @@ -841,13 +1055,40 @@ declare namespace request { remove(callback: AsyncCallback): void; /** - * Deletes a upload session. + * Remove a upload session. * @syscap SystemCapability.MiscServices.Upload * @since 6 + * @deprecated since 9 * @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; } } diff --git a/api/@system.request.d.ts b/api/@system.request.d.ts index 9c946b7d73..92c95249fb 100644 --- a/api/@system.request.d.ts +++ b/api/@system.request.d.ts @@ -15,12 +15,14 @@ /** * @syscap SystemCapability.MiscServices.Upload + * @deprecated since 9 */ 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 -- Gitee From 0e4f11353806483104b875d6248edd83a8a1725c Mon Sep 17 00:00:00 2001 From: nagexiucai Date: Thu, 22 Sep 2022 20:47:08 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=84=E5=AE=A1?= =?UTF-8?q?=E6=84=8F=E8=A7=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nagexiucai --- api/@ohos.request.d.ts | 129 +++++++++++++-------------------------- api/@system.request.d.ts | 2 +- 2 files changed, 43 insertions(+), 88 deletions(-) diff --git a/api/@ohos.request.d.ts b/api/@ohos.request.d.ts index 10d7cd3e60..78e4d55f6c 100644 --- a/api/@ohos.request.d.ts +++ b/api/@ohos.request.d.ts @@ -44,58 +44,23 @@ declare namespace request { * @since 9 */ const EXCEPTION_UNSUPPORTED: number; - /** - * http response status code is not ok - * @errorcode 13400001 - * @syscap SystemCapability.MiscServices.Download - * @since 9 - */ - const EXCEPTION_RESPONSE: number; /** * file operation error - * @errorcode 13400002 + * @errorcode 13400001 * @syscap SystemCapability.MiscServices.Download * @since 9 */ const EXCEPTION_FILEIO: number; - /** - * get/compute file size error - * @errorcode 13400003 - * @syscap SystemCapability.MiscServices.Download - * @since 9 - */ - const EXCEPTION_FILESIZE: number; /** * bad file path - * @errorcode 13400004 + * @errorcode 13400002 * @syscap SystemCapability.MiscServices.Download * @since 9 */ const EXCEPTION_FILEPATH: number; /** - * task timeout - * @errorcode 13400005 - * @syscap SystemCapability.MiscServices.Download - * @since 9 - */ - const EXCEPTION_TASKTIMEOUT: number; - /** - * exceed task retries limit - * @errorcode 13400006 - * @syscap SystemCapability.MiscServices.Download - * @since 9 - */ - const EXCEPTION_TASKRETRIES: number; - /** - * da error - * @errorcode 13400007 - * @syscap SystemCapability.MiscServices.Download - * @since 9 - */ - const EXCEPTION_DATABASE: number; - /** - * sa error - * @errorcode 13400008 + * task manager service error + * @errorcode 13400003 * @syscap SystemCapability.MiscServices.Download * @since 9 */ @@ -128,7 +93,6 @@ declare namespace request { * Indicates that the download cannot be resumed for some temporary errors. * @syscap SystemCapability.MiscServices.Download * @since 7 - * @deprecated since 9 * @permission ohos.permission.INTERNET */ const ERROR_CANNOT_RESUME: number; @@ -137,7 +101,6 @@ declare namespace request { * Indicates that no storage device, such as an SD card, is found. * @syscap SystemCapability.MiscServices.Download * @since 7 - * @deprecated since 9 * @permission ohos.permission.INTERNET */ const ERROR_DEVICE_NOT_FOUND: number; @@ -146,7 +109,6 @@ declare namespace request { * Indicates that files to be downloaded already exist, and that the download session cannot overwrite the existing files. * @syscap SystemCapability.MiscServices.Download * @since 7 - * @deprecated since 9 * @permission ohos.permission.INTERNET */ const ERROR_FILE_ALREADY_EXISTS: number; @@ -155,7 +117,6 @@ declare namespace request { * Indicates that a file operation fails. * @syscap SystemCapability.MiscServices.Download * @since 7 - * @deprecated since 9 * @permission ohos.permission.INTERNET */ const ERROR_FILE_ERROR: number; @@ -164,7 +125,6 @@ declare namespace request { * Indicates that the HTTP transmission fails. * @syscap SystemCapability.MiscServices.Download * @since 7 - * @deprecated since 9 * @permission ohos.permission.INTERNET */ const ERROR_HTTP_DATA_ERROR: number; @@ -173,7 +133,6 @@ declare namespace request { * Indicates insufficient storage space. * @syscap SystemCapability.MiscServices.Download * @since 7 - * @deprecated since 9 * @permission ohos.permission.INTERNET */ const ERROR_INSUFFICIENT_SPACE: number; @@ -182,7 +141,6 @@ declare namespace request { * Indicates an error caused by too many network redirections. * @syscap SystemCapability.MiscServices.Download * @since 7 - * @deprecated since 9 * @permission ohos.permission.INTERNET */ const ERROR_TOO_MANY_REDIRECTS: number; @@ -191,7 +149,6 @@ declare namespace request { * Indicates an HTTP code that cannot be identified. * @syscap SystemCapability.MiscServices.Download * @since 7 - * @deprecated since 9 * @permission ohos.permission.INTERNET */ const ERROR_UNHANDLED_HTTP_CODE: number; @@ -200,11 +157,26 @@ declare namespace request { * Indicates an undefined error. * @syscap SystemCapability.MiscServices.Download * @since 7 - * @deprecated since 9 * @permission ohos.permission.INTERNET */ 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 @@ -281,7 +253,7 @@ declare namespace request { * Starts a download session. * @syscap SystemCapability.MiscServices.Download * @since 6 - * @deprecated since 9 + * @deprecated since 9, use 'downloadFile' instead. * @param config download config * @param callback Indicate the callback function to receive DownloadTask. * @permission ohos.permission.INTERNET @@ -301,23 +273,18 @@ declare namespace request { * @throws {BusinessError} if exception occurs * @errorcode EXCEPTION_PERMISSION * @errorcode EXCEPTION_PARAMCHECK - * @errorcode EXCEPTION_RESPONSE * @errorcode EXCEPTION_FILEIO - * @errorcode EXCEPTION_FILESIZE * @errorcode EXCEPTION_FILEPATH - * @errorcode EXCEPTION_TASKTIMEOUT - * @errorcode EXCEPTION_TASKRETRIES - * @errorcode EXCEPTION_DATABASE * @errorcode EXCEPTION_SERVICE * @return - */ - function downloadV9(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 + * @deprecated since 9, use 'downloadFile' instead. * @param config download config * @permission ohos.permission.INTERNET * @return - @@ -335,23 +302,18 @@ declare namespace request { * @throws {BusinessError} if exception occurs * @errorcode EXCEPTION_PERMISSION * @errorcode EXCEPTION_PARAMCHECK - * @errorcode EXCEPTION_RESPONSE * @errorcode EXCEPTION_FILEIO - * @errorcode EXCEPTION_FILESIZE * @errorcode EXCEPTION_FILEPATH - * @errorcode EXCEPTION_TASKTIMEOUT - * @errorcode EXCEPTION_TASKRETRIES - * @errorcode EXCEPTION_DATABASE * @errorcode EXCEPTION_SERVICE * @return - */ - function downloadV9(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 + * @deprecated since 9, use 'uploadFile' instead. * @param config upload config * @param callback Indicate the callback function to receive UploadTask. * @permission ohos.permission.INTERNET @@ -371,19 +333,16 @@ declare namespace request { * @throws {BusinessError} if exception occurs * @errorcode EXCEPTION_PERMISSION * @errorcode EXCEPTION_PARAMCHECK - * @errorcode EXCEPTION_RESPONSE - * @errorcode EXCEPTION_FILEIO - * @errorcode EXCEPTION_FILESIZE * @errorcode EXCEPTION_FILEPATH * @return - */ - function uploadV9(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 + * @deprecated since 9, use 'uploadFile' instead. * @param config upload config * @permission ohos.permission.INTERNET * @return - @@ -401,13 +360,10 @@ declare namespace request { * @throws {BusinessError} if exception occurs * @errorcode EXCEPTION_PERMISSION * @errorcode EXCEPTION_PARAMCHECK - * @errorcode EXCEPTION_RESPONSE - * @errorcode EXCEPTION_FILEIO - * @errorcode EXCEPTION_FILESIZE * @errorcode EXCEPTION_FILEPATH * @return - */ - function uploadV9(context: BaseContext, config: UploadConfig): Promise; + function uploadFile(context: BaseContext, config: UploadConfig): Promise; /** * DownloadConfig data Structure @@ -653,7 +609,7 @@ declare namespace request { * Deletes a download session and the downloaded files. * @syscap SystemCapability.MiscServices.Download * @since 6 - * @deprecated since 9 + * @deprecated since 9, use 'delete' instead. * @param callback Indicates asynchronous invoking Result. * @permission ohos.permission.INTERNET * @return - @@ -664,7 +620,7 @@ declare namespace request { * Deletes a download session and the downloaded files. * @syscap SystemCapability.MiscServices.Download * @since 6 - * @deprecated since 9 + * @deprecated since 9, use 'delete' instead. * @permission ohos.permission.INTERNET * @return - */ @@ -674,7 +630,7 @@ declare namespace request { * Pause a download session. * @syscap SystemCapability.MiscServices.Download * @since 7 - * @deprecated since 9 + * @deprecated since 9, use 'suspend' instead. * @param callback Indicates asynchronous invoking Result. * @permission ohos.permission.INTERNET * @return - @@ -685,7 +641,7 @@ declare namespace request { * Pause a download session. * @syscap SystemCapability.MiscServices.Download * @since 7 - * @deprecated since 9 + * @deprecated since 9, use 'suspend' instead. * @permission ohos.permission.INTERNET * @return - */ @@ -695,7 +651,7 @@ declare namespace request { * Resume a paused download session. * @syscap SystemCapability.MiscServices.Download * @since 7 - * @deprecated since 9 + * @deprecated since 9, use 'restore' instead. * @param callback Indicates asynchronous invoking Result. * @permission ohos.permission.INTERNET * @return - @@ -706,7 +662,7 @@ declare namespace request { * Resume a paused download session. * @syscap SystemCapability.MiscServices.Download * @since 7 - * @deprecated since 9 + * @deprecated since 9, use 'restore' instead. * @permission ohos.permission.INTERNET * @return - */ @@ -716,7 +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 + * @deprecated since 9, use 'getTaskInfo' instead. * @param callback Indicate the callback function to receive download info. * @permission ohos.permission.INTERNET * @return - @@ -727,7 +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 + * @deprecated since 9, use 'getTaskInfo' instead. * @permission ohos.permission.INTERNET * @return - */ @@ -737,7 +693,7 @@ declare namespace request { * Queries the MIME type of the download file. * @syscap SystemCapability.MiscServices.Download * @since 7 - * @deprecated since 9 + * @deprecated since 9, use 'getTaskMimeType' instead. * @param callback Indicate the callback function to receive download file MIME type. * @permission ohos.permission.INTERNET * @return - @@ -748,7 +704,7 @@ declare namespace request { * Queries the MIME type of the download file. * @syscap SystemCapability.MiscServices.Download * @since 7 - * @deprecated since 9 + * @deprecated since 9, use 'getTaskMimeType' instead. * @permission ohos.permission.INTERNET * @return - */ @@ -822,7 +778,7 @@ declare namespace request { * @syscap SystemCapability.MiscServices.Download */ getTaskMimeType(callback: AsyncCallback): void; - getTaskMimeType(callback: AsyncCallback): void; + getTaskMimeType(): Promise; } /** @@ -886,7 +842,7 @@ declare namespace request { * @since 6 * @permission ohos.permission.INTERNET */ - value: string|ArrayBuffer; + value: string; } /** @@ -1047,7 +1003,7 @@ declare namespace request { * Remove a upload session. * @syscap SystemCapability.MiscServices.Upload * @since 6 - * @deprecated since 9 + * @deprecated since 9, use 'delete' instead. * @param callback Indicates asynchronous invoking Result. * @permission ohos.permission.INTERNET * @return - @@ -1058,7 +1014,7 @@ declare namespace request { * Remove a upload session. * @syscap SystemCapability.MiscServices.Upload * @since 6 - * @deprecated since 9 + * @deprecated since 9, use 'delete' instead. * @permission ohos.permission.INTERNET * @return - */ @@ -1093,4 +1049,3 @@ declare namespace request { } export default request; - diff --git a/api/@system.request.d.ts b/api/@system.request.d.ts index 92c95249fb..27c2a23aba 100644 --- a/api/@system.request.d.ts +++ b/api/@system.request.d.ts @@ -15,7 +15,7 @@ /** * @syscap SystemCapability.MiscServices.Upload - * @deprecated since 9 + * @deprecated since 9, use '@ohos.request' instead. */ export interface UploadResponse { /** -- Gitee