I'm using mongoDB to store 2 files, and I get those messages:
DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
this is my code, I have no idea where should I pass those options to:
var storageImage = new GridFsStorage({
url: dbURI,
file: (req, file) => {
return new Promise((resolve, reject) => {
crypto.randomBytes(16, (err, buf) => {
if (err) {
return reject(err);
}
const filename = buf.toString("hex") + path.extname(file.originalname);
const fileInfo = {
filename: filename,
bucketName: "user_images"
};
resolve(fileInfo);
});
});
}
});
const uploadImage = multer({ storage: storageImage });
var storageDoc = new GridFsStorage({
url: dbURI,
file: (req, file) => {
return new Promise((resolve, reject) => {
crypto.randomBytes(16, (err, buf) => {
if (err) {
return reject(err);
}
const filename = buf.toString("hex") + path.extname(file.originalname);
const fileInfo = {
filename: filename,
bucketName: "user_cv"
};
resolve(fileInfo);
});
});
}
});
const uploadDoc = multer({ storage: storageDoc });
//routes
router.post("/uploadImage", uploadImage.single("file"), (req, res) => {
console.log(req.file);
res.json({ imageId: req.file.id });
});
router.post("/uploadCV", uploadDoc.single("file"), (req, res) => {
console.log(req.file);
res.json({ cvId: req.file.id });
});
module.exports = router;
Try like this. Adding this line should work options: { useNewUrlParser: true }
.
new GridFsStorage({
url: dbURI,
options: { useNewUrlParser: true },
...,
});