harmony 鸿蒙Upload and Download Subsystem ChangeLog
Upload and Download Subsystem ChangeLog
Compared with OpenHarmony 3.2 Beta3, OpenHarmony 3.2.8.1 has the following changes in its upload and download subsystem:
cl.request.1 Changes of Error Code Definitions and Some API Names
- The processing of the upload and download error codes is added to the upload and download APIs.
- An error message is returned via AsyncCallback or the error object of Promise. An error message related to the parameter type or quantity is returned via an exception.
- Some APIs need to be replaced with new APIs, and the parameters remain unchanged.
Change Impacts
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/Enumeration/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 |
Added |
ohos.request | request | function downloadFile(context: BaseContext, config: DownloadConfig): Promise |
Added |
ohos.request | request | function uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback |
Added |
ohos.request | request | function uploadFile(context: BaseContext, config: UploadConfig): Promise |
Added |
ohos.request | DownloadTask | delete(callback: AsyncCallback |
Added |
ohos.request | DownloadTask | delete(): Promise |
Added |
ohos.request | DownloadTask | suspend(callback: AsyncCallback |
Added |
ohos.request | DownloadTask | suspend(): Promise |
Added |
ohos.request | DownloadTask | restore(callback: AsyncCallback |
Added |
ohos.request | DownloadTask | restore(): Promise |
Added |
ohos.request | DownloadTask | getTaskInfo(callback: AsyncCallback |
Added |
ohos.request | DownloadTask | getTaskInfo(): Promise |
Added |
ohos.request | DownloadTask | getTaskMimeType(callback: AsyncCallback |
Added |
ohos.request | DownloadTask | getTaskMimeType(): Promise |
Added |
ohos.request | UploadTask | delete(callback: AsyncCallback |
Added |
ohos.request | UploadTask | delete(): Promise |
Added |
ohos.request | request | function download(config: DownloadConfig, callback: AsyncCallback Substitute API: function downloadFile(context: BaseContext, config: DownloadConfig, callback: AsyncCallback |
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 Substitute API: function downloadFile(context: BaseContext, config: DownloadConfig, callback: AsyncCallback |
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 Substitute API: function uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback |
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 Substitute API: function uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback |
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 Substitute API: delete(callback: AsyncCallback |
Deprecated |
ohos.request | DownloadTask | remove(): Promise Substitute API: delete(): Promise |
Deprecated |
ohos.request | DownloadTask | pause(callback: AsyncCallback Substitute API: suspend(callback: AsyncCallback |
Deprecated |
ohos.request | DownloadTask | pause(): Promise Substitute API: suspend(): Promise |
Deprecated |
ohos.request | DownloadTask | resume(callback: AsyncCallback Substitute API: restore(callback: AsyncCallback |
Deprecated |
ohos.request | DownloadTask | resume(): Promise Substitute API: restore(): Promise |
Deprecated |
ohos.request | DownloadTask | query(callback: AsyncCallback Substitute API: getTaskInfo(callback: AsyncCallback |
Deprecated |
ohos.request | DownloadTask | query(): Promise Substitute API: getTaskInfo(): Promise |
Deprecated |
ohos.request | DownloadTask | queryMimeType(callback: AsyncCallback Substitute API: getTaskMimeType(callback: AsyncCallback |
Deprecated |
ohos.request | DownloadTask | queryMimeType(): Promise Substitute API: getTaskMimeType(): Promise |
Deprecated |
ohos.request | UploadTask | remove(callback: AsyncCallback Substitute API: delete(callback: AsyncCallback |
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 uses downloadFile as an example to show how it is called in the new version:
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);
}
你可能感兴趣的鸿蒙文章
harmony 鸿蒙Account Subsystem ChangeLog
harmony 鸿蒙ChangeLog of JS API Changes in the Multimedia Subsystem
harmony 鸿蒙Device Manager ChangeLog
harmony 鸿蒙USB Manager ChangeLog
harmony 鸿蒙DSoftBus Subsystem ChangeLog
harmony 鸿蒙File Management Subsystem ChangeLog
harmony 鸿蒙Globalization Subsystem ChangeLog
harmony 鸿蒙Input Method Framework ChangeLog
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦