Updated: Warehouse image endpoint logic

This commit is contained in:
Llewellyn D'souza
2021-12-29 09:57:49 +05:30
parent e221527ae8
commit edd8ff9bb2
2 changed files with 13 additions and 3 deletions

View File

@@ -60,8 +60,18 @@ module.exports = {
*/
addWarehouseImage: async (req, res, next) => {
// req.file contains the `warehouse-image`
console.dir({ file: req.file });
res.send("ok");
console.dir("Warehouse image uploaded:", { file: req.file });
const { id } = req.params;
try {
const warehouseDetails = await Warehouse.findById(id);
warehouseDetails.imageUrl = req.file.path;
await warehouseDetails.save();
res.send({ success: true, data: warehouseDetails });
} catch (err) {
next(err);
}
},
/**