How to use multipart/form-data in NodeJS? #1134
Replies: 2 comments
-
Hello @pedromtcosta ! Just this package is template driven and you can redefine part of swagger schema fields which your swagger schema is using. Main target for this project is browser, I'm trying to help you how to better create this function Also you can try rewrite fully http-client template as you want |
Beta Was this translation helpful? Give feedback.
-
Hi @js2me ! Basically, the problem with my solution is that I have to provide a file name, which contains the file extension, so generating a "random" name would not work. One thing that could work nicely for this case is if I can somehow map
then the only problem I'd have in this case is that I'd need to change the
|
Beta Was this translation helpful? Give feedback.
-
The client gets generated with the
createFormData
function that is used when the request content ismultipart/form-data
. The problem is that this function uses the typesBlob
andFile
, which are not available in the NodeJS runtime:using
primitiveTypeConstructs
to changestring.binary
fromFile
toBuffer
for example does not work for 2 reasons:createFormData
still uses theBlob
andFile
types;Buffer
type lacks some stuff that's needed to upload a file withFormData
, such as the file name;Just as a test, I changed the
createFormData
function to be like the one below and it worked nicely in an API I am testing with, but this is obviously not a good solution:so, is it possible to use
multipart/form-data
in NodeJS?Beta Was this translation helpful? Give feedback.
All reactions