Merge pull request #850 from Bilb/communicate-file-size-limit-user

show error when user try to add file >10mb as attachment
pull/857/head
Audric Ackermann 5 years ago committed by GitHub
commit f47d1fd9ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -204,10 +204,10 @@
}); });
}, },
showFileSizeError() { showFileSizeError(limit, units) {
window.pushToast({ window.pushToast({
title: i18n('fileSizeWarning'), title: i18n('fileSizeWarning'),
description: `Max size: ${this.model.limit} ${this.model.units}`, description: `Max size: ${limit} ${units}`,
type: 'error', type: 'error',
id: 'fileSizeWarning', id: 'fileSizeWarning',
}); });
@ -339,7 +339,7 @@
contentType, contentType,
file, file,
}); });
let limitKb = 1000000; let limitKb = 10000;
const blobType = const blobType =
file.type === 'image/gif' ? 'gif' : contentType.split('/')[0]; file.type === 'image/gif' ? 'gif' : contentType.split('/')[0];
@ -348,19 +348,19 @@
limitKb = 6000; limitKb = 6000;
break; break;
case 'gif': case 'gif':
limitKb = 25000; limitKb = 10000;
break; break;
case 'audio': case 'audio':
limitKb = 100000; limitKb = 10000;
break; break;
case 'video': case 'video':
limitKb = 100000; limitKb = 10000;
break; break;
default: default:
limitKb = 100000; limitKb = 10000;
break; break;
} }
if ((blob.size / 1024).toFixed(4) >= limitKb) { if ((blob.file.size / 1024).toFixed(4) >= limitKb) {
const units = ['kB', 'MB', 'GB']; const units = ['kB', 'MB', 'GB'];
let u = -1; let u = -1;
let limit = limitKb * 1000; let limit = limitKb * 1000;
@ -368,7 +368,7 @@
limit /= 1000; limit /= 1000;
u += 1; u += 1;
} while (limit >= 1000 && u < units.length - 1); } while (limit >= 1000 && u < units.length - 1);
this.showFileSizeError(); this.showFileSizeError(limit, units[u]);
return; return;
} }
} catch (error) { } catch (error) {

Loading…
Cancel
Save