Commit 5accdc6f by Jose Antonio

Merged branch develop into develop

parents 2fde7804 d0caa7d0
...@@ -1199,24 +1199,21 @@ module.exports = { ...@@ -1199,24 +1199,21 @@ module.exports = {
upload_sound: function (req, res) { upload_sound: function (req, res) {
var soundFileName; var soundFileName;
var soundDirectory = sails.config.pictogram.paths.pictoSoundDirectory; var soundDirectory = sails.config.pictogram.paths.pictoSoundDirectory;
console.log("Llega aqui 1");
soundFileName = sails.config.pictogram.paths.getCustomPictoSoundFilename(req.params.id_stu_picto); soundFileName = sails.config.pictogram.paths.getCustomPictoSoundFilename(req.params.id_stu_picto);
console.log("Llega aqui 2");
req.file('file').upload({ req.file('file').upload({
maxBytes: 1048576, maxBytes: 1048576,
dirname: soundDirectory, dirname: soundDirectory,
saveAs: soundFileName saveAs: soundFileName
}, function whenDone(err, uploadedFiles) { }, function whenDone(err, uploadedFiles) {
console.log("Llega aqui 3");
var fs = require('fs'); var fs = require('fs');
if (err || (uploadedFiles.length === 0)) if (err || (uploadedFiles.length === 0))
return res.serverError("Error uploading " + err ? err : ""); return res.serverError("Error uploading " + err ? err : "");
console.log("Llega aqui 4"); StuPicto.findOne({ id: req.params.id_stu_picto })
StuPicto.findOne({ id: req.params.id_stu_picto}) .then((sp) => {
.then(sp => { if (!sp)
console.log("Picto encontrado") throw Error("Not found");
sp.attributes.uri_sound = soundFileName; sp.attributes.uri_sound = soundFileName;
sp.save(function (err) { sp.save(function (err) {
if (err) throw err; if (err) throw err;
......
...@@ -137,8 +137,8 @@ module.exports = { ...@@ -137,8 +137,8 @@ module.exports = {
if (!((/^#([0-9a-f]{3}){1,2}$/i).test(validAttributes.color))) { if (!((/^#([0-9a-f]{3}){1,2}$/i).test(validAttributes.color))) {
delete validAttributes.color; delete validAttributes.color;
} }
if (typeof validAttributes.sound_uri!== 'string') { if (typeof validAttributes.uri_sound!== 'string') {
delete validAttributes.sound_uri; delete validAttributes.uri_sound;
} }
if (typeof validAttributes.user_avatar !== 'string') { if (typeof validAttributes.user_avatar !== 'string') {
delete validAttributes.user_avatar; delete validAttributes.user_avatar;
......
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