multer-gridfs-storage

Explain Like I'm Five: Form w/ Text and Image Field > Routes > Controller > Write to MongoDB Document - GridFS goes where?

南笙酒味 提交于 2021-02-11 16:33:08
问题 I have been trying to read the documentation for GridFS and MongoDB for awhile. They just keep repeating the same thing and I can't make sense of it. Desired Output: The user submits a form that form contains many fields, but one is an image. The request needs to store the data in a collection and make a new document, which can be retrieved later. My main question is how do I use GridFS in this situation to store an image in that document. It says GridFS makes two collections in my database

Explain Like I'm Five: Form w/ Text and Image Field > Routes > Controller > Write to MongoDB Document - GridFS goes where?

浪尽此生 提交于 2021-02-11 16:28:52
问题 I have been trying to read the documentation for GridFS and MongoDB for awhile. They just keep repeating the same thing and I can't make sense of it. Desired Output: The user submits a form that form contains many fields, but one is an image. The request needs to store the data in a collection and make a new document, which can be retrieved later. My main question is how do I use GridFS in this situation to store an image in that document. It says GridFS makes two collections in my database

How can I delete a file with multer gridfs storage?

好久不见. 提交于 2021-02-11 14:37:49
问题 The following code works as expected to upload and retrieve files: // Mongo URI const mongoURI = 'mongodbconnstring'; // // Create mongo connection const conn = mongoose.createConnection(mongoURI); // // Init gfs let gfs; conn.once('open', () => { gfs = new mongoose.mongo.GridFSBucket(conn.db, { bucketName: 'Uploads' }); }); // Create storage engine const storage = new GridFsStorage({ url: mongoURI, file: (req, file) => { return new Promise((resolve, reject) => { const filename = file

How can I delete a file with multer gridfs storage?

老子叫甜甜 提交于 2021-02-11 14:35:05
问题 The following code works as expected to upload and retrieve files: // Mongo URI const mongoURI = 'mongodbconnstring'; // // Create mongo connection const conn = mongoose.createConnection(mongoURI); // // Init gfs let gfs; conn.once('open', () => { gfs = new mongoose.mongo.GridFSBucket(conn.db, { bucketName: 'Uploads' }); }); // Create storage engine const storage = new GridFsStorage({ url: mongoURI, file: (req, file) => { return new Promise((resolve, reject) => { const filename = file

Multer gridfs storage referencing uploaded file to a new collection

一笑奈何 提交于 2019-12-12 01:19:41
问题 Uploaded file using multer gridfs storage i want to reference it to newly created collection (movies). The fileID i referenced to the uploaded file is not the same with the uploaded file, even with that the movies collection is not saved on to the database. The fileID i referenced to the uploaded file is not the same with the uploaded file, even with that the movies collection is not saved on the database //movie schema const mongoose = require('mongoose'); const Schema = mongoose.Schema;

How do i add new field other than multer-gridfs-storage default properties

末鹿安然 提交于 2019-12-08 13:22:22
问题 I wanted to add new fields (objects) other than multer-gridfs-storage default fields but to no avail, the fields i want to add are: Description category Token The default field has something like _id length chunksize uploadDate md5 contentType instead want to add something like _id length chunksize uploadDate md5 contentType description category and the rest And also is there a way to add a thumbnail to file so i don't i have reference my file id to the thumbnail in other collection const