mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-25 05:54:25 -04:00
better handling of image uploads
This commit is contained in:
parent
63b207466b
commit
90a9482f2a
@ -61,8 +61,8 @@
|
||||
}
|
||||
});
|
||||
this.$emit('uploaded', ids);
|
||||
} catch {
|
||||
this.errorMessage = 'error.generic';
|
||||
} catch (e) {
|
||||
this.errorMessage = e?.response?.data?.error || 'error.invalidImage';
|
||||
}
|
||||
this.uploading = false;
|
||||
},
|
||||
|
@ -1052,6 +1052,7 @@ images:
|
||||
|
||||
error:
|
||||
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:
|
||||
reason: 'Please prove you''re not a bot to mitigate spam and DDoS attacks.'
|
||||
|
@ -1209,6 +1209,7 @@ images:
|
||||
|
||||
error:
|
||||
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:
|
||||
reason: 'Please prove you''re not a bot to mitigate spam and DDoS attacks.'
|
||||
|
@ -123,5 +123,6 @@ module.exports = [
|
||||
'mode.reducedItems',
|
||||
'user.socialLookup',
|
||||
'user.socialLookupWhy',
|
||||
'api.source'
|
||||
'api.source',
|
||||
'error.invalidImage',
|
||||
];
|
||||
|
@ -1801,6 +1801,7 @@ images:
|
||||
|
||||
error:
|
||||
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:
|
||||
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 = [];
|
||||
for (let file of req.files) {
|
||||
const id = ulid();
|
||||
let image;
|
||||
try {
|
||||
const image = await loadImage(await sharp(file.buffer).png().toBuffer());
|
||||
image = await loadImage(await sharp(file.buffer).png().toBuffer());
|
||||
} catch {
|
||||
return res.status(400).json({error: 'File type not supported'});
|
||||
return res.status(400).json({error: 'error.invalidImage'});
|
||||
}
|
||||
|
||||
for (let s in sizes) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user