diff --git a/packages/hoppscotch-common/src/helpers/new-codegen/har.ts b/packages/hoppscotch-common/src/helpers/new-codegen/har.ts index b8c9e49c..c9fc285c 100644 --- a/packages/hoppscotch-common/src/helpers/new-codegen/har.ts +++ b/packages/hoppscotch-common/src/helpers/new-codegen/har.ts @@ -114,6 +114,29 @@ const buildHarPostData = (req: HoppRESTRequest): Har.PostData | undefined => { } } + // application/octet-stream bodies are File | null; emit @filename for file uploads + if (req.body.contentType === "application/octet-stream") { + const file = req.body.body + + if (!file) { + return { + mimeType: req.body.contentType, + text: "", + } + } + + // `path` exists in some desktop runtimes; `name` is the standard File field. + const filename = + "path" in file && typeof file.path === "string" && file.path + ? file.path + : file.name || "" + + return { + mimeType: req.body.contentType, + text: `@${filename}`, + } + } + return { mimeType: req.body.contentType, // Let's assume by default content type is JSON text: (req.body.body as string) ?? "",