From 89cf5d25fa7920cd5093da457b3c5b18d2e2894c Mon Sep 17 00:00:00 2001 From: shen <409724179@qq.com> Date: Fri, 1 Nov 2024 08:06:21 +0000 Subject: [PATCH] =?UTF-8?q?update=20ohos/src/main/ets/components/FlutterDo?= =?UTF-8?q?wnloaderPlugin.ets.=20=E4=BF=AE=E5=A4=8D=E9=9C=80=E8=A6=81Heade?= =?UTF-8?q?rs=E9=89=B4=E6=9D=83=E4=B8=8B=E8=BD=BD=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shen <409724179@qq.com> --- .../main/ets/components/FlutterDownloaderPlugin.ets | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ohos/src/main/ets/components/FlutterDownloaderPlugin.ets b/ohos/src/main/ets/components/FlutterDownloaderPlugin.ets index 7c09bf9..eddd08d 100644 --- a/ohos/src/main/ets/components/FlutterDownloaderPlugin.ets +++ b/ohos/src/main/ets/components/FlutterDownloaderPlugin.ets @@ -497,13 +497,21 @@ export class FlutterDownloaderPlugin implements FlutterPlugin, MethodCallHandler filename = this.renameSavedFile(filename); savedFile = `${saveFileDir}/${filename}`; } + let headersMap: Map; + try { + headersMap = new Map(Object.entries(headers)); + } catch (error) { + console.error(error.message); + headersMap =new Map(); + } const requestConfig: request.agent.Config = { action: request.agent.Action.DOWNLOAD, url: url, saveas: tempFile, metered: allowCellular, overwrite: true, - gauge: showNotification + gauge: showNotification, + headers:headersMap }; const downloadTask = await request.agent.create(this.context!, requestConfig); -- Gitee