![]() ![]() I configure multer to keep the uploaded file in memory. The GET photo route takes a Mongo ObjectID as a parameter to retrieve the image. mongodb (official mongodb nodejs driver).multer (for handling multipart/form-data requests). ![]() express (nodejs web application framework to simplify this snippet).This will include setting up the express server, mongodb driver, defining the routes and handling the GET and POST routes. The question is quite broad as such my answer will be an entire nodejs program. My example will be using the new GridFSBucket API. One previous answer has indeed utilized the official mongodb driver, however they use the Gridstore API which has since been deprecated, see here. Answers so far are good, however, I believe it would be beneficial to document here how to do this using the official mongodb nodejs driver instead of relying on further abstractions such as "gridfs-stream".
0 Comments
Leave a Reply. |