I'm using NextJS
endpoint to receive fromData
with file/files
I need to parse the file's data and use metadata to decide the file name in the Multer
storage.
For example, based on the file name, I would like to create an entry in the DB for Users "profile" and use that Entry ID for the file path in Multer storage (Upladoing to GCP bucket)
What I need is a way for Multer to let me have access to the file data before initiating the storage object - in which I need to provide the file's destination
before it's known to me.
I tried:
Multer
middlewares, the first one has no storage object configured, and the second one has it."multer Unexpected end of form"
when the data is going out to the remote destination. - seems like it was ruining its own file parsingMulter
alongside formidable
files
key to the req
object so Mulert could upload it. But Multer
kept overwriting it with an empty arraystring
calculated at the time of upload, just at initializationSolutions in Express.JS will be easily understood if you have a solution, not for Next.Js I'
For anyone who might be stuck with a similar issue. I can't recommend adding using a combination of middlewares to process the form data.
But something that worked for me is to send the data I needed in the request's query string.
It ain't pretty, but it works and saves a lot of time to find another way to submit the file's data