Skip to content

Commit d24c084

Browse files
committed
Check filesize before uploading file to server and display alert if file is too big.
Signed-off-by: Nicolas Buquet <[email protected]>
1 parent 087f0cc commit d24c084

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Riot/Modules/Room/RoomViewController.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7721,6 +7721,15 @@ - (void)documentPickerPresenter:(MXKDocumentPickerPresenter *)presenter didPickD
77217721
{
77227722
self.documentPickerPresenter = nil;
77237723

7724+
// Check maxUploadSize accepted by the home server before trying to upload.
7725+
NSUInteger maxUploadFileSize = self.roomDataSource.mxSession.maxUploadSize;
7726+
NSDictionary *fileAttributes = [NSFileManager.defaultManager attributesOfItemAtPath:url.path error:nil];
7727+
if (fileAttributes && fileAttributes.fileSize > maxUploadFileSize) {
7728+
[self showAlertWithTitle:@"The file you want to upload is too big."
7729+
message:[NSString stringWithFormat:@"\nThe file you want to upload is too big.\n\nIt mustn't weight more than %ldMB", maxUploadFileSize/(1024*1024)]];
7730+
return;
7731+
}
7732+
77247733
MXKUTI *fileUTI = [[MXKUTI alloc] initWithLocalFileURL:url];
77257734
NSString *mimeType = fileUTI.mimeType;
77267735

changelog.d/pr-7778.change

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Check filesize before uploading file to server and display alert if file is too big.

0 commit comments

Comments
 (0)