The user uploads the avatar through node.js to the remote file system next to the database, then each session loads it back. What kind of node.js modules can one-time jpg file transfer?
- oneas an option to use multer github.com/expressjs/multer - C.Raf.T
1 answer
You will need fs modules for working with files (for example, moving, renaming), formidabble is a module for working with multipart forms, allows you to separately process text fields with form.on('field', function (field, value) { and form.on('field', function (field, value) { , for example, images by form.on('file', function (field, file) { . To return images to the frontend, you will need node-static . To save the addresses of the images (to draw the desired image in the front), you need to remember the location of the image in database, you can use the module to Mongu and it mongoose. Ditto for the User the You can make your own folder on a server for everyone (it is possible on the main server, or on a special server for pictures and files), calling it, for example, a unique user id, so you can not only find the avatar from the database, but also come up with something API