Skip to content

Commit

Permalink
fix: video uploads larger than ~100MB fail on iOS (#239)
Browse files Browse the repository at this point in the history
* Video uploads larger than ~100MB fail on iOS

Closes #172 #149 #53 #93
  • Loading branch information
kasterlod committed May 6, 2021
1 parent 25f76c1 commit d5798e0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ios/VydiaRNFileUploader.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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

0 comments on commit d5798e0

Please sign in to comment.