I want to parse a multipart form twice: once to grab the incoming fields, and later to process the file upload.
I am trying to maintain a proper separation of concerns within my Node app:
- Controller is responsible for handling the incoming fields.
- Model is responsible for the upload file logic.
I need to pass the fields data into the model to create a new instance, so the fields data needs to be available before the file upload starts.
Currently every form.parse()
or equivalent function parses both fields and files together. Example: req.pipe(busboy)
handles both file and fields together.
I have checked modules like node-multiparty, formidable, busboy, multer. Nobody seems to have a solution for this.
An example of what I would like to achieve is here: https://stackoverflow.com/questions/22336177/node-js-busboy-parse-fields-and-files-seperatly
Is this even possible?