picto upload now is an update

parent ca165925
Showing with 32 additions and 18 deletions
...@@ -563,23 +563,37 @@ module.exports = { ...@@ -563,23 +563,37 @@ module.exports = {
if (err || (uploadedFiles.length === 0)) if (err || (uploadedFiles.length === 0))
return res.serverError("Error uploading " + err ? err : ""); return res.serverError("Error uploading " + err ? err : "");
if (req.body.id_pic!=null && req.body.id>=0) {
Picto.create({ query = {
uri: pictoFileName, id: req.body.id_pic
source: 2, // 1 -> SymbolStix, 2 -> custom }
owner: supervisor.id Picto.update(query, {
}) uri:pictoFileName
.then(picto => { })
return res.ok(picto); .then(updated => {
}) return res.ok(updated);
.catch(err => { })
fs.unlink(uploadedFiles[0].fd); .catch(err => {
return res.serverError("Error uploading " + err); return res.serverError('Unable to upload picto: ' + err);
}); });
}); }
}) else
.catch(function (err) { Picto.create({
return res.serverError("Error uploading picto: " + err); uri: pictoFileName,
}); source: 2, // 1 -> SymbolStix, 2 -> custom
owner: supervisor.id
})
.then(picto => {
return res.ok(picto);
})
.catch(err => {
fs.unlink(uploadedFiles[0].fd);
return res.serverError("Error uploading " + err);
});
});
})
.catch(function (err) {
return res.serverError("Error uploading picto: " + err);
});
} }
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment