issue #774 fixed

parent 21816551
......@@ -293,7 +293,7 @@ module.exports = {
sails.log.debug("Uploading picto with FileName: " + pictoFileName);
req.file('file').upload({
maxBytes: 1000000,
maxBytes: 1048576,
dirname: pictoDirectory,
saveAs: pictoFileName
}, function whenDone(err, uploadedFiles) {
......
......@@ -1007,12 +1007,12 @@ module.exports = {
newAvatarFileName = sails.config.pictogram.paths.getStudentAvatarFileName(student.id);
req.file('file').upload({
maxBytes: 1000000,
maxBytes: 1048576,
dirname: newAvatarDirectory,
saveAs: newAvatarFileName
}, function whenDone(error, uploadedFiles) {
if (error || (uploadedFiles.length === 0)) {
throw new Error("upload failed");
return res.badRequest("Upload failed");
}
try {
......
......@@ -530,12 +530,12 @@ module.exports = {
sails.log.debug("Saving file to " + newAvatarDirectory + "/" + newAvatarFileName);
req.file('file').upload({
maxBytes: 1000000,
maxBytes: 1048576,
dirname: newAvatarDirectory,
saveAs: newAvatarFileName
}, function whenDone(error, uploadedFiles) {
if (error || (uploadedFiles.length === 0)) {
throw new Error("upload failed");
return res.badRequest("Upload failed");
}
try {
......
......@@ -100,6 +100,7 @@
"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_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_general": "An error has been produced",
"expand_navigation": "Expand navigation",
......
......@@ -103,6 +103,7 @@
"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_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_general": "Se ha producido un error",
"February": "Febrero",
......
......@@ -63,9 +63,14 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl(
ngToast.success({ content: $translate.instant('student_updated') });
$scope.studentData.pic = '/upload/studentAvatar/' + data.file.name;
$scope.spin_disabled = true;
})
.error(function (err) {
ngToast.danger({content: $translate.instant('error_on_upload')});
$scope.spin_disabled = true;
});
} else {
ngToast.danger({ content: $translate.instant('error_only_support_images') });
$scope.spin_disabled = true;
}
}
};
......
......@@ -62,10 +62,12 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl(
$scope.spin_disabled = true;
})
.error(function (err) {
console.log("ERROR while uploading image: " + err);
ngToast.danger({content: $translate.instant('error_on_upload')});
$scope.spin_disabled = true;
});
} else {
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