mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-25 14:09:03 -04:00
better handling of image uploads
This commit is contained in:
parent
63b207466b
commit
90a9482f2a
@ -61,8 +61,8 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.$emit('uploaded', ids);
|
this.$emit('uploaded', ids);
|
||||||
} catch {
|
} catch (e) {
|
||||||
this.errorMessage = 'error.generic';
|
this.errorMessage = e?.response?.data?.error || 'error.invalidImage';
|
||||||
}
|
}
|
||||||
this.uploading = false;
|
this.uploading = false;
|
||||||
},
|
},
|
||||||
|
@ -1052,6 +1052,7 @@ images:
|
|||||||
|
|
||||||
error:
|
error:
|
||||||
generic: 'Something went wrong, please try again…'
|
generic: 'Something went wrong, please try again…'
|
||||||
|
invalidImage: 'This file does''t seem right. Make sure it''s a valid image under 10 MB.'
|
||||||
|
|
||||||
captcha:
|
captcha:
|
||||||
reason: 'Please prove you''re not a bot to mitigate spam and DDoS attacks.'
|
reason: 'Please prove you''re not a bot to mitigate spam and DDoS attacks.'
|
||||||
|
@ -1209,6 +1209,7 @@ images:
|
|||||||
|
|
||||||
error:
|
error:
|
||||||
generic: 'Something went wrong, please try again…'
|
generic: 'Something went wrong, please try again…'
|
||||||
|
invalidImage: 'This file does''t seem right. Make sure it''s a valid image under 10 MB.'
|
||||||
|
|
||||||
captcha:
|
captcha:
|
||||||
reason: 'Please prove you''re not a bot to mitigate spam and DDoS attacks.'
|
reason: 'Please prove you''re not a bot to mitigate spam and DDoS attacks.'
|
||||||
|
@ -123,5 +123,6 @@ module.exports = [
|
|||||||
'mode.reducedItems',
|
'mode.reducedItems',
|
||||||
'user.socialLookup',
|
'user.socialLookup',
|
||||||
'user.socialLookupWhy',
|
'user.socialLookupWhy',
|
||||||
'api.source'
|
'api.source',
|
||||||
|
'error.invalidImage',
|
||||||
];
|
];
|
||||||
|
@ -1801,6 +1801,7 @@ images:
|
|||||||
|
|
||||||
error:
|
error:
|
||||||
generic: 'Coś poszło nie tak, spróbuj ponownie…'
|
generic: 'Coś poszło nie tak, spróbuj ponownie…'
|
||||||
|
invalidImage: 'Nieobsługiwany format pliku. Upewnij się, że wgrywasz poprawny obrazek nie cięższy niż 10 MB.'
|
||||||
|
|
||||||
captcha:
|
captcha:
|
||||||
reason: 'Prosimy o udowodnienie, że nie jesteś botem, by chronić się przed spamem i DDoS-ami'
|
reason: 'Prosimy o udowodnienie, że nie jesteś botem, by chronić się przed spamem i DDoS-ami'
|
||||||
|
@ -59,10 +59,11 @@ router.post('/images/upload', multer({limits: {fileSize: 10 * 1024 * 1024}}).any
|
|||||||
const ids = [];
|
const ids = [];
|
||||||
for (let file of req.files) {
|
for (let file of req.files) {
|
||||||
const id = ulid();
|
const id = ulid();
|
||||||
|
let image;
|
||||||
try {
|
try {
|
||||||
const image = await loadImage(await sharp(file.buffer).png().toBuffer());
|
image = await loadImage(await sharp(file.buffer).png().toBuffer());
|
||||||
} catch {
|
} catch {
|
||||||
return res.status(400).json({error: 'File type not supported'});
|
return res.status(400).json({error: 'error.invalidImage'});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let s in sizes) {
|
for (let s in sizes) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user