# Upload and Download Changelog ## cl.request.1 Changes of Error Code Definitions and API Names - Processing of [error codes](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/errorcodes/errorcode-request.md) is added to the upload and download APIs. - Error information is returned via the **error** object in **AsyncCallback** or **Promise**. Wherein, parameter type or quantity error information is returned by throwing an exception. - Some APIs are replaced with new APIs, but the parameters remain unchanged. **Change Impact** The application developed based on earlier versions needs to adapt the method for returning API error information. Otherwise, the original service logic will be affected. **Key API/Component Changes** | Module | Class | Method/Attribute/Enum/Constant | Change Type | |--------------|--------------|-----------------------------------------------------------------------------------------------------------------------|-----------| | ohos.request | request | EXCEPTION_PERMISSION | Added| | ohos.request | request | EXCEPTION_PARAMCHECK | Added| | ohos.request | request | EXCEPTION_UNSUPPORTED | Added| | ohos.request | request | EXCEPTION_FILEIO | Added| | ohos.request | request | EXCEPTION_FILEPATH | Added| | ohos.request | request | EXCEPTION_SERVICE | Added| | ohos.request | request | EXCEPTION_OTHERS | Added| | ohos.request | request | ERROR_OFFLINE | Added| | ohos.request | request | ERROR_UNSUPPORTED_NETWORK_TYPE | Added| | ohos.request | request | function downloadFile(context: BaseContext, config: DownloadConfig, callback: AsyncCallback): void; | Added| | ohos.request | request | function downloadFile(context: BaseContext, config: DownloadConfig): Promise; | Added| | ohos.request | request | function uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback): void; | Added| | ohos.request | request | function uploadFile(context: BaseContext, config: UploadConfig): Promise; | Added| | ohos.request | DownloadTask | delete(callback: AsyncCallback): void; | Added| | ohos.request | DownloadTask | delete(): Promise; | Added| | ohos.request | DownloadTask | suspend(callback: AsyncCallback): void; | Added| | ohos.request | DownloadTask | suspend(): Promise; | Added| | ohos.request | DownloadTask | restore(callback: AsyncCallback): void; | Added| | ohos.request | DownloadTask | restore(): Promise; | Added| | ohos.request | DownloadTask | getTaskInfo(callback: AsyncCallback): void; | Added| | ohos.request | DownloadTask | getTaskInfo(): Promise; | Added| | ohos.request | DownloadTask | getTaskMimeType(callback: AsyncCallback): void; | Added| | ohos.request | DownloadTask | getTaskMimeType(): Promise; | Added| | ohos.request | UploadTask | delete(callback: AsyncCallback): void; | Added| | ohos.request | UploadTask | delete(): Promise; | Added| | ohos.request | request | function download(config: DownloadConfig, callback: AsyncCallback): void;
Substitute API: function downloadFile(context: BaseContext, config: DownloadConfig, callback: AsyncCallback): void;| Deprecated| | ohos.request | request | function download(config: DownloadConfig): Promise;
Substitute API: function downloadFile(context: BaseContext, config: DownloadConfig): Promise; | Deprecated| | ohos.request | request | function download(context: BaseContext, config: DownloadConfig, callback: AsyncCallback): void;
Substitute API: function downloadFile(context: BaseContext, config: DownloadConfig, callback: AsyncCallback): void;| Deprecated| | ohos.request | request | function download(context: BaseContext, config: DownloadConfig): Promise;
Substitute API: function downloadFile(context: BaseContext, config: DownloadConfig): Promise; | Deprecated| | ohos.request | request | function upload(config: UploadConfig, callback: AsyncCallback): void;
Substitute API: function uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback): void; | Deprecated| | ohos.request | request | function upload(config: UploadConfig): Promise;
Substitute API: function uploadFile(context: BaseContext, config: UploadConfig): Promise; | Deprecated| | ohos.request | request | function upload(context: BaseContext, config: UploadConfig, callback: AsyncCallback): void;
Substitute API: function uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback): void; | Deprecated| | ohos.request | request | function upload(context: BaseContext, config: UploadConfig): Promise;
Substitute API: function uploadFile(context: BaseContext, config: UploadConfig): Promise; | Deprecated| | ohos.request | DownloadTask | remove(callback: AsyncCallback): void;
Substitute API: delete(callback: AsyncCallback): void | Deprecated| | ohos.request | DownloadTask | remove(): Promise;
Substitute API: delete(): Promise; | Deprecated| | ohos.request | DownloadTask | pause(callback: AsyncCallback): void;
Substitute API: suspend(callback: AsyncCallback): void; | Deprecated| | ohos.request | DownloadTask | pause(): Promise;
Substitute API: suspend(): Promise; | Deprecated| | ohos.request | DownloadTask | resume(callback: AsyncCallback): void;
Substitute API: restore(callback: AsyncCallback): void; | Deprecated| | ohos.request | DownloadTask | resume(): Promise;
Substitute API: restore(): Promise; | Deprecated| | ohos.request | DownloadTask | query(callback: AsyncCallback): void;
Substitute API: getTaskInfo(callback: AsyncCallback): void; | Deprecated| | ohos.request | DownloadTask | query(): Promise;
Substitute API: getTaskInfo(): Promise; | Deprecated| | ohos.request | DownloadTask | queryMimeType(callback: AsyncCallback): void;
Substitute API: getTaskMimeType(callback: AsyncCallback): void; | Deprecated| | ohos.request | DownloadTask | queryMimeType(): Promise;
Substitute API: getTaskMimeType(): Promise; | Deprecated| | ohos.request | UploadTask | remove(callback: AsyncCallback): void;
Substitute API: delete(callback: AsyncCallback): void; | Deprecated| | ohos.request | UploadTask | remove(): Promise;
Substitute API: delete(): Promise; | Deprecated| | system.request | UploadResponse | code | Deprecated| | system.request | UploadResponse | data | Deprecated| | system.request | UploadResponse | headers | Deprecated| | system.request | DownloadResponse | token | Deprecated| | system.request | OnDownloadCompleteResponse | uri | Deprecated| | system.request | RequestFile | filename | Deprecated| | system.request | RequestFile | name | Deprecated| | system.request | RequestFile | uri | Deprecated| | system.request | RequestFile | type | Deprecated| | system.request | RequestData | name | Deprecated| | system.request | RequestData | value | Deprecated| | system.request | UploadRequestOptions | url | Deprecated| | system.request | UploadRequestOptions | data | Deprecated| | system.request | UploadRequestOptions | files | Deprecated| | system.request | UploadRequestOptions | header | Deprecated| | system.request | UploadRequestOptions | description | Deprecated| | system.request | UploadRequestOptions | success | Deprecated| | system.request | UploadRequestOptions | fail | Deprecated| | system.request | UploadRequestOptions | complete | Deprecated| | system.request | OnDownloadCompleteOptions | token | Deprecated| | system.request | OnDownloadCompleteOptions | success | Deprecated| | system.request | OnDownloadCompleteOptions | fail | Deprecated| | system.request | OnDownloadCompleteOptions | complete | Deprecated| | system.request | Request | static upload(options: UploadRequestOptions): void; | Deprecated| | system.request | Request | static download(options: DownloadRequestOptions): void; | Deprecated| | system.request | Request | static onDownloadComplete(options: OnDownloadCompleteOptions): void; | Deprecated| **Adaptation Guide** The following sample code shows how to call **downloadFile** in the new version: ```ts try { request.downloadFile(globalThis.abilityContext, { url: 'https://xxxx/xxxxx.hap', filePath: 'xxx/xxxxx.hap'}, (err, data) => { if (err) { console.error('Failed to request the download. Cause: ' + JSON.stringify(err)); return; } }); } catch (err) { console.log("downloadFile callback fail." + "errCode:" + err.code + ",errMessage:" + err.message); } ```