0
Good morning, I’m building an api on nodejs to access mongodb. I want to add images in this database and return the path of this image to my android application. I want to store the images directly in the bank or using Postman. Does anyone have any idea how I add the images in mongodb?
Here is the current code.
medicoRouter.post('/medicos', (req, res, next)=>{
async function salvaMedico(){
const medicos = new Medicos({
nome: req.body.nome,
formacao: req.body.formacao,
crm: req.body.crm,
cidade: req.body.cidade,
//caminho_foto: url_imagem,
//data_atualizacao: null
});
try{
const result = await medicos.save();
console.log("Operação realizada com sucesso");
res.status(201).send({ message: "Cadastrado com sucesso!"});
/* res.statusCode = 201;
res.send(); */
} catch(erro){
console.log(erro.message);
res.status(406).send({ message: "Cadastro falhou"});
/* res.statusCode = 406;
res.send(); */
}
}
salvaMedico();
});