'MERN - how to get back uploaded file via FormData JavaScript API and render it in forntend?

I have sent file via formData JS API to express. There, I have used Buffer.from(JSON.stringify(uploadedFile)) and stored it into mongo via mongoose driver; For sending it back to the client, I used uploadedFile.toString("utf8"); Now, on the frontend, I have file, but don't know how to access it or show preview. Since it is not local, I cannot usee URL.createObjeclUrl to preview it.

On express, I've used express-formidable package for data upload



Solution 1:[1]

You can simply use multer. Multer is middleware for Express and Node.js that makes it easy to handle this multipart/form-data when your users upload files. Find the below link and go through it and you will find the answer.

https://code.tutsplus.com/tutorials/file-upload-with-multer-in-node--cms-32088

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 hasintha Doluweera