0
In addition to uploading the images I do a treatment on them with Sharp, uploading only 1 image with upload.single('image')
the treatment is executed and the image is saved, but when I try an array with upload.array('image', 10)
images are saved without receiving the treatment.
The treatment happens in the controller:
async post (req, res) {
const { title, description, locale, resume } = req.body;
const { filename : image } = req.file;
const [name] = image.split('.');
const filename = `${name}.jpg`;
await sharp(req.file.path)
.resize(600)
.jpeg({ quality: 80 })
.toFile(
path.resolve(req.file.destination, 'obras', filename)
)
fs.unlinkSync(req.file.path);
const obra = await Obra.create({
success: true,
title,
description,
resume,
locale,
image: filename,
});
return res.json( obra );
},
how to do the same treatment on all images I send?