richardgirges / express-fileupload

Simple express file upload middleware that wraps around busboy
MIT License
1.52k stars 261 forks source link

Need help, please #289

Closed viccabezos closed 2 years ago

viccabezos commented 2 years ago

Hi! first of all sorry for using the issues as a way to have some help, i've been trying to find a clear answer for more than a week and couldn´t...

i think it's easy but i have just not being able to resolve this...

so until now i was uploagind only pnj files. now i want to upload pnj and pdf... front part is working already but i have a problem in my back-end and i don't understand how to do this. couldn't find any exemple either....

should i make 2 if? 2 different try? it has something to do with the mimetype?

im lost

export const uploadImageForTechnialReport = async (req, res) => { try { if (!req?.files?.image) return res.status(422).jsonp("NO_IMAGE_PROVIDED");

const url = await upload(req.files.image.data);

return res.status(200).send(url);

} catch (err) { return res.status(400).send(AN_ERROR_OCCURED_${err.message}); } };