Express - how do I use sharp with multer?
17:10 13 Oct 2020

I need help with using sharp, I want my images to resize when uploaded but I can't seem to get this right.

router.post("/", upload.single("image"), async (req, res) => {
    const { filename: image } = req.file;

    await sharp(req.file.path)
        .resize(300, 200)
        .jpeg({ quality: 50 })
        .toFile(path.resolve(req.file.destination, "resized", image));

    fs.unlinkSync(req.file.path);
    res.send("sent");
});
node.js express multer sharp