中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
http并行下载的实现方式
微信扫码分享
import { request } from '@kit.BasicServicesKit'; import { BusinessError } from '@kit.BasicServicesKit'; let downloadTask: request.DownloadTask; try { request.downloadFile(getContext(), { url: 'https://xxxx/xxxx.hap' }).then((data: request.DownloadTask) => { downloadTask = data; }).catch((err: BusinessError) => { console.error(`Failed to request the download. Code: ${err.code}, message: ${err.message}`); }) } catch (err) { console.error(`Failed to request the download. err: ${JSON.stringify(err)}`); }