From 53c4801744ae4cbe2fca1ea297d8e6c4bb680619 Mon Sep 17 00:00:00 2001 From: sarankumar <120080287+sarankumar1325@users.noreply.github.com> Date: Fri, 27 Nov 2026 15:04:42 +0530 Subject: [PATCH] fix(upload): accept a plain object for headers (#3797) * fix(upload): accept a plain object for headers Signed-off-by: sarankumar1325 <120080287+sarankumar1325@users.noreply.github.com> * Update .changes/upload-headers-record.md Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com> * Apply suggestion from @lucasfernog --------- Signed-off-by: sarankumar1325 <120080287+sarankumar1325@users.noreply.github.com> Co-authored-by: Lucas Fernandes Nogueira Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com> --- .changes/upload-headers-record.md | 6 ++++++ plugins/upload/guest-js/index.ts | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .changes/upload-headers-record.md diff --git a/.changes/upload-headers-record.md b/.changes/upload-headers-record.md new file mode 100644 index 000000000..71bb50849 --- /dev/null +++ b/.changes/upload-headers-record.md @@ -0,0 +1,6 @@ +--- +upload: patch +upload-js: patch +--- + +Accept a plain object for the `headers` argument of `upload` and `download`, as shown in their examples, in addition to a `Map`. diff --git a/plugins/upload/guest-js/index.ts b/plugins/upload/guest-js/index.ts index 2783cbe91..02d45ab17 100644 --- a/plugins/upload/guest-js/index.ts +++ b/plugins/upload/guest-js/index.ts @@ -89,8 +89,8 @@ async function upload( url: string, filePath: string, progressHandler?: ProgressHandler, - // TODO: V3 - Combine headers and methods into one `options` object - headers?: Map, + // TODO: V3 - Combine headers and methods into one `options` object, switch to HeadersInit + headers?: Record | Map, method?: HttpMethod ): Promise { const ids = new Uint32Array(1) @@ -142,7 +142,7 @@ async function download( url: string, filePath: string, progressHandler?: ProgressHandler, - headers?: Map, + headers?: Record | Map, body?: string ): Promise { const ids = new Uint32Array(1)