picto upload now is an update

parent ca165925
Showing with 32 additions and 18 deletions
......@@ -563,23 +563,37 @@ module.exports = {
if (err || (uploadedFiles.length === 0))
return res.serverError("Error uploading " + err ? err : "");
Picto.create({
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);
});
if (req.body.id_pic!=null && req.body.id>=0) {
query = {
id: req.body.id_pic
}
Picto.update(query, {
uri:pictoFileName
})
.then(updated => {
return res.ok(updated);
})
.catch(err => {
return res.serverError('Unable to upload picto: ' + err);
});
}
else
Picto.create({
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