1# Upload and Download Changelog 2 3 4## cl.request.2 Upload and Download API Change 5 6- Deleted the beta APIs in API version 9: 71. function download(context: BaseContext, config: DownloadConfig, callback: AsyncCallback<DownloadTask>): void; 82. function download(context: BaseContext, config: DownloadConfig): Promise<DownloadTask>; 93. function upload(context: BaseContext, config: UploadConfig, callback: AsyncCallback<UploadTask>): void; 104. function upload(context: BaseContext, config: UploadConfig): Promise<UploadTask>; 11 12**Change Impact** 13 14The application developed based on the Stage mode of earlier versions needs to be adapted. Otherwise, the service logic will be affected. 15 16**Key API/Component Changes** 17 18| Module | Class | Method/Attribute/Enum/Constant | Change Type| 19|--------------|--------------|-------------------------------------------------------------------------------------------------------------------|------| 20| ohos.request | request | function download(context: BaseContext, config: DownloadConfig, callback: AsyncCallback<DownloadTask>): void; | Deleted. | 21| ohos.request | request | function download(context: BaseContext, config: DownloadConfig): Promise<DownloadTask>; | Deleted. | 22| ohos.request | request | function upload(context: BaseContext, config: UploadConfig, callback: AsyncCallback<UploadTask>): void; | Deleted. | 23| ohos.request | request | function upload(context: BaseContext, config: UploadConfig): Promise<UploadTask>; | Deleted. | 24 25 26**Adaptation Guide** 27 28The following sample code shows how to call **downloadFile** in the new version: 29 30```ts 31try { 32 request.downloadFile(globalThis.abilityContext, { url: 'https://xxxx/xxxxx.hap', 33 filePath: 'xxx/xxxxx.hap'}, (err, data) => { 34 if (err) { 35 console.error('Failed to request the download. Cause: ' + JSON.stringify(err)); 36 return; 37 } 38 }); 39} catch (err) { 40 console.log("downloadFile callback fail." + "errCode:" + err.code + ",errMessage:" + err.message); 41} 42``` 43