Skip to content

Commit dfc6806

Browse files
authored
Merge pull request #600 from nadav2051/bugfix/ios-fix-create-file-base64
Bugfix/ios fix create file base64
2 parents 28f4a54 + 2911626 commit dfc6806

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

ios/RNFetchBlob/RNFetchBlob.m

+7-2
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ - (NSDictionary *)constantsToExport
165165
fileContent = [[NSData alloc] initWithData:[data dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]];
166166
}
167167
else if([[encoding lowercaseString] isEqualToString:@"base64"]) {
168-
fileContent = [[NSData alloc] initWithBase64EncodedData:data options:0];
168+
fileContent = [[NSData alloc] initWithBase64EncodedData:data options:NSDataBase64DecodingIgnoreUnknownCharacters];
169169
}
170170
else if([[encoding lowercaseString] isEqualToString:@"uri"]) {
171171
NSString * orgPath = [data stringByReplacingOccurrencesOfString:FILE_PREFIX withString:@""];
@@ -639,7 +639,12 @@ - (NSDictionary *)constantsToExport
639639
- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller
640640
{
641641
UIWindow *window = [UIApplication sharedApplication].keyWindow;
642-
return window.rootViewController;
642+
UIViewController *currentlyPresentedView = [window.rootViewController presentedViewController];
643+
if (currentlyPresentedView == nil)
644+
{
645+
return window.rootViewController;
646+
}
647+
return currentlyPresentedView;
643648
}
644649

645650
# pragma mark - check expired network events

polyfill/Fetch.js

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class RNFetchBlobFetchPolyfill {
4141
promise = Blob.build(body).then((b) => {
4242
blobCache = b
4343
options.headers['Content-Type'] = 'multipart/form-data;boundary=' + b.multipartBoundary
44+
options.headers['content-type'] = 'multipart/form-data;boundary=' + b.multipartBoundary
4445
return Promise.resolve(RNFetchBlob.wrap(b._ref))
4546
})
4647
}

0 commit comments

Comments
 (0)