From 3212e978b329e16f90b67d806a94e6aa11721365 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Mon, 2 May 2016 11:48:37 -0400 Subject: [PATCH] (fix) handle correctly files being uploaded that are bigger than limit --- UI/Contacts/UIxContactFolderActions.m | 12 +++++++++++- UI/Scheduler/UIxCalFolderActions.m | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/UI/Contacts/UIxContactFolderActions.m b/UI/Contacts/UIxContactFolderActions.m index 9fbc81850..09b27a29f 100644 --- a/UI/Contacts/UIxContactFolderActions.m +++ b/UI/Contacts/UIxContactFolderActions.m @@ -111,7 +111,17 @@ request = [context request]; rc = [NSMutableDictionary dictionary]; - data = [[[[[request httpRequest] body] parts] lastObject] body]; + data = [[request httpRequest] body]; + + // We got an exception, that means the file upload limit + // has been reached. + if ([data isKindOfClass: [NSException class]]) + { + response = [self responseWithStatus: 507]; + return response; + } + + data = [[[data parts] lastObject] body]; fileContent = [[NSString alloc] initWithData: (NSData *) data encoding: NSUTF8StringEncoding]; diff --git a/UI/Scheduler/UIxCalFolderActions.m b/UI/Scheduler/UIxCalFolderActions.m index 8226b6b0b..07d227edb 100644 --- a/UI/Scheduler/UIxCalFolderActions.m +++ b/UI/Scheduler/UIxCalFolderActions.m @@ -77,7 +77,17 @@ rc = [NSMutableDictionary dictionary]; request = [context request]; folder = [self clientObject]; - data = [[[[[request httpRequest] body] parts] lastObject] body]; + data = [[request httpRequest] body]; + + // We got an exception, that means the file upload limit + // has been reached. + if ([data isKindOfClass: [NSException class]]) + { + response = [self responseWithStatus: 507]; + return response; + } + + data = [[[data parts] lastObject] body]; fileContent = [[NSString alloc] initWithData: (NSData *) data encoding: NSUTF8StringEncoding];