Subida de audio terminada en la API

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