What is the correct way to store files in database
I'm working on mevn app, where I'm confused with storing the user files in database. I'm using mongodb for storage and multer to get files as buffer.
Is it compulsory to convert buffer into file(say .png) and then store it on database or we should store buffer directly?
If we convert buffer into file, then we need to delete it from server's memory. For small application we can can convert it into file , but for large application this task will take a lot of time and memory. Also, memory leak might be an issue.
Also, is there any common way to compress image and deliver it to client side (like facebook does).
Thanks in advance