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.
Uh oh!
There was an error while loading. Please reload this page.
-
The client gets generated with the
createFormDatafunction that is used when the request content ismultipart/form-data. The problem is that this function uses the typesBlobandFile, which are not available in the NodeJS runtime:using
primitiveTypeConstructsto changestring.binaryfromFiletoBufferfor example does not work for 2 reasons:createFormDatastill uses theBlobandFiletypes;Buffertype lacks some stuff that's needed to upload a file withFormData, such as the file name;Just as a test, I changed the
createFormDatafunction 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-datain NodeJS?Beta Was this translation helpful? Give feedback.
All reactions