harmony 鸿蒙Upload and Download Subsystem Changelog

  • 2023-06-24
  • 浏览 (357)

Upload and Download Subsystem Changelog

cl.request.2 Upload and Download API Change

  • Deleted the beta APIs in API version 9:
  • function download(context: BaseContext, config: DownloadConfig, callback: AsyncCallback): void;
  • function download(context: BaseContext, config: DownloadConfig): Promise;
  • function upload(context: BaseContext, config: UploadConfig, callback: AsyncCallback): void;
  • function upload(context: BaseContext, config: UploadConfig): Promise;

Change Impact

The application developed based on the Stage mode of earlier versions needs to be adapted. Otherwise, the service logic will be affected.

Key API/Component Changes

Module Class Method/Attribute/Enumeration/Constant Change Type
ohos.request request function download(context: BaseContext, config: DownloadConfig, callback: AsyncCallback): void; Deleted.
ohos.request request function download(context: BaseContext, config: DownloadConfig): Promise; Deleted.
ohos.request request function upload(context: BaseContext, config: UploadConfig, callback: AsyncCallback): void; Deleted.
ohos.request request function upload(context: BaseContext, config: UploadConfig): Promise; Deleted.

Adaptation Guide

The following sample code shows how to call downloadFile 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 鸿蒙Readme

harmony 鸿蒙Example Subsystem Changelog

harmony 鸿蒙Ability Framework Changelog

harmony 鸿蒙Account Subsystem Changelog

harmony 鸿蒙ArkUI Subsystem ChangeLog

harmony 鸿蒙Multimedia Subsystem Changelog

harmony 鸿蒙Common Library Subsystem Changelog

harmony 鸿蒙Distributed Data Management Subsystem JS API Changelog

harmony 鸿蒙File Management Subsystem Changelog

harmony 鸿蒙Input Method Framework ChangeLog

0  赞