From 3d37a9fb92f858d81783d209c08f367e9351ef22 Mon Sep 17 00:00:00 2001 From: Kacper Szeliga Date: Tue, 23 Feb 2021 22:27:17 +0100 Subject: [PATCH 1/2] Video uploads larger than ~100MB fail on iOS --- ios/VydiaRNFileUploader.m | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ios/VydiaRNFileUploader.m b/ios/VydiaRNFileUploader.m index 7e11e5f5..132b3642 100644 --- a/ios/VydiaRNFileUploader.m +++ b/ios/VydiaRNFileUploader.m @@ -196,7 +196,8 @@ - (void)copyAssetToFile: (NSString *)assetUrl completionHandler: (void(^)(NSStri [request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", uuidStr] forHTTPHeaderField:@"Content-Type"]; NSData *httpBody = [self createBodyWithBoundary:uuidStr path:fileURI parameters: parameters fieldName:fieldName]; - [request setHTTPBody: httpBody]; + [request setHTTPBodyStream: [NSInputStream inputStreamWithData:httpBody]]; + [request setValue:[NSString stringWithFormat:@"%zd", httpBody.length] forHTTPHeaderField:@"Content-Length"]; uploadTask = [[self urlSession: appGroup] uploadTaskWithStreamedRequest:request]; } else { @@ -343,4 +344,15 @@ - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)data } } +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task + needNewBodyStream:(void (^)(NSInputStream *bodyStream))completionHandler { + + NSInputStream *inputStream = task.originalRequest.HTTPBodyStream; + + if (completionHandler) { + completionHandler(inputStream); + } +} + @end From 47eb5c76268782500add7cf89b90daa84c85317b Mon Sep 17 00:00:00 2001 From: Kacper Szeliga Date: Tue, 23 Feb 2021 22:27:17 +0100 Subject: [PATCH 2/2] Video uploads larger than ~100MB fail on iOS --- ios/VydiaRNFileUploader.m | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ios/VydiaRNFileUploader.m b/ios/VydiaRNFileUploader.m index f2f91801..cd57c443 100644 --- a/ios/VydiaRNFileUploader.m +++ b/ios/VydiaRNFileUploader.m @@ -199,7 +199,8 @@ - (void)copyAssetToFile: (NSString *)assetUrl completionHandler: (void(^)(NSStri [request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", uuidStr] forHTTPHeaderField:@"Content-Type"]; NSData *httpBody = [self createBodyWithBoundary:uuidStr path:fileURI parameters: parameters fieldName:fieldName]; - [request setHTTPBody: httpBody]; + [request setHTTPBodyStream: [NSInputStream inputStreamWithData:httpBody]]; + [request setValue:[NSString stringWithFormat:@"%zd", httpBody.length] forHTTPHeaderField:@"Content-Length"]; uploadTask = [[self urlSession: appGroup] uploadTaskWithStreamedRequest:request]; } else { @@ -354,4 +355,15 @@ - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)data } } +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task + needNewBodyStream:(void (^)(NSInputStream *bodyStream))completionHandler { + + NSInputStream *inputStream = task.originalRequest.HTTPBodyStream; + + if (completionHandler) { + completionHandler(inputStream); + } +} + @end