issue #774 fixed

parent 21816551
...@@ -293,7 +293,7 @@ module.exports = { ...@@ -293,7 +293,7 @@ module.exports = {
sails.log.debug("Uploading picto with FileName: " + pictoFileName); sails.log.debug("Uploading picto with FileName: " + pictoFileName);
req.file('file').upload({ req.file('file').upload({
maxBytes: 1000000, maxBytes: 1048576,
dirname: pictoDirectory, dirname: pictoDirectory,
saveAs: pictoFileName saveAs: pictoFileName
}, function whenDone(err, uploadedFiles) { }, function whenDone(err, uploadedFiles) {
......
...@@ -1007,12 +1007,12 @@ module.exports = { ...@@ -1007,12 +1007,12 @@ module.exports = {
newAvatarFileName = sails.config.pictogram.paths.getStudentAvatarFileName(student.id); newAvatarFileName = sails.config.pictogram.paths.getStudentAvatarFileName(student.id);
req.file('file').upload({ req.file('file').upload({
maxBytes: 1000000, maxBytes: 1048576,
dirname: newAvatarDirectory, dirname: newAvatarDirectory,
saveAs: newAvatarFileName saveAs: newAvatarFileName
}, function whenDone(error, uploadedFiles) { }, function whenDone(error, uploadedFiles) {
if (error || (uploadedFiles.length === 0)) { if (error || (uploadedFiles.length === 0)) {
throw new Error("upload failed"); return res.badRequest("Upload failed");
} }
try { try {
......
...@@ -530,12 +530,12 @@ module.exports = { ...@@ -530,12 +530,12 @@ module.exports = {
sails.log.debug("Saving file to " + newAvatarDirectory + "/" + newAvatarFileName); sails.log.debug("Saving file to " + newAvatarDirectory + "/" + newAvatarFileName);
req.file('file').upload({ req.file('file').upload({
maxBytes: 1000000, maxBytes: 1048576,
dirname: newAvatarDirectory, dirname: newAvatarDirectory,
saveAs: newAvatarFileName saveAs: newAvatarFileName
}, function whenDone(error, uploadedFiles) { }, function whenDone(error, uploadedFiles) {
if (error || (uploadedFiles.length === 0)) { if (error || (uploadedFiles.length === 0)) {
throw new Error("upload failed"); return res.badRequest("Upload failed");
} }
try { try {
......
...@@ -100,6 +100,7 @@ ...@@ -100,6 +100,7 @@
"error_only_support_images": "Only images are supported (JPG, PNG or GIF files)", "error_only_support_images": "Only images are supported (JPG, PNG or GIF files)",
"error_on_request": "The request has not been processed. Please, check your fields", "error_on_request": "The request has not been processed. Please, check your fields",
"error_on_request_sup_not_found": "Account not found or it has not been activated", "error_on_request_sup_not_found": "Account not found or it has not been activated",
"error_on_upload": "Error on image upload. The maximum allowed size for images is 1 MB.",
"error_loading_pictos": "Error loading pictos information", "error_loading_pictos": "Error loading pictos information",
"error_general": "An error has been produced", "error_general": "An error has been produced",
"expand_navigation": "Expand navigation", "expand_navigation": "Expand navigation",
......
...@@ -103,6 +103,7 @@ ...@@ -103,6 +103,7 @@
"error_only_support_images": "Sólo se soportan imágenes (ficheros JPG, PNG o GIF)", "error_only_support_images": "Sólo se soportan imágenes (ficheros JPG, PNG o GIF)",
"error_on_request": "Se ha producido un error. Por favor, compruebe los valores introducidos.", "error_on_request": "Se ha producido un error. Por favor, compruebe los valores introducidos.",
"error_on_request_sup_not_found": "La cuenta no existe o no ha sido activada", "error_on_request_sup_not_found": "La cuenta no existe o no ha sido activada",
"error_on_upload": "Error al subir la imagen. Compruebe que el archivo no supera 1MB de tamaño.",
"error_loading_pictos": "Error cargando información de los pictos", "error_loading_pictos": "Error cargando información de los pictos",
"error_general": "Se ha producido un error", "error_general": "Se ha producido un error",
"February": "Febrero", "February": "Febrero",
......
...@@ -63,9 +63,14 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl( ...@@ -63,9 +63,14 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl(
ngToast.success({ content: $translate.instant('student_updated') }); ngToast.success({ content: $translate.instant('student_updated') });
$scope.studentData.pic = '/upload/studentAvatar/' + data.file.name; $scope.studentData.pic = '/upload/studentAvatar/' + data.file.name;
$scope.spin_disabled = true; $scope.spin_disabled = true;
})
.error(function (err) {
ngToast.danger({content: $translate.instant('error_on_upload')});
$scope.spin_disabled = true;
}); });
} else { } else {
ngToast.danger({ content: $translate.instant('error_only_support_images') }); ngToast.danger({ content: $translate.instant('error_only_support_images') });
$scope.spin_disabled = true;
} }
} }
}; };
......
...@@ -62,10 +62,12 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl( ...@@ -62,10 +62,12 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl(
$scope.spin_disabled = true; $scope.spin_disabled = true;
}) })
.error(function (err) { .error(function (err) {
console.log("ERROR while uploading image: " + err); ngToast.danger({content: $translate.instant('error_on_upload')});
$scope.spin_disabled = true;
}); });
} else { } else {
ngToast.danger({ content: $translate.instant('error_only_support_images') }); ngToast.danger({ content: $translate.instant('error_only_support_images') });
$scope.spin_disabled = true;
} }
} }
}; };
......
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