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