From 3db7d54acad3cccbe8282a2467302824f7241c23 Mon Sep 17 00:00:00 2001 From: Sanjai Kumar <84461672+sanjai0py@users.noreply.github.com> Date: Tue, 18 Jun 2024 17:05:09 +0530 Subject: [PATCH] bugfix(#2462) (#2463) * fixed * refactor: conditionals. * refactor: Update importPostmanV2CollectionItem function to handle file and text formdata --- .../src/utils/importers/postman-collection.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/bruno-app/src/utils/importers/postman-collection.js b/packages/bruno-app/src/utils/importers/postman-collection.js index e34530a19..dc291dbdb 100644 --- a/packages/bruno-app/src/utils/importers/postman-collection.js +++ b/packages/bruno-app/src/utils/importers/postman-collection.js @@ -180,12 +180,27 @@ const importPostmanV2CollectionItem = (brunoParent, item, parentAuth, options) = if (bodyMode) { if (bodyMode === 'formdata') { brunoRequestItem.request.body.mode = 'multipartForm'; + each(i.request.body.formdata, (param) => { + const isFile = param.type === 'file'; + let value; + let type; + + if (isFile) { + // If param.src is an array, keep it as it is. + // If param.src is a string, convert it into an array with a single element. + value = Array.isArray(param.src) ? param.src : typeof param.src === 'string' ? [param.src] : null; + type = 'file'; + } else { + value = param.value; + type = 'text'; + } + brunoRequestItem.request.body.multipartForm.push({ uid: uuid(), - type: 'text', + type: type, name: param.key, - value: param.value, + value: value, description: param.description, enabled: !param.disabled });