mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-01-12 22:50:10 +08:00
Fix exception when attempt to load image from file system (#24457)
Summary: When trying to load image using method "RCTImageFromLocalAssetURL", if URL's path in file system representation return null (in my case, imageUrl is base64 format returned from server so it's always null) then method "stringWithUTF8String" will raise an exception. [iOS] [Fixed] - Fix exception when attempt to load image from file system Pull Request resolved: https://github.com/facebook/react-native/pull/24457 Differential Revision: D15123680 Pulled By: shergin fbshipit-source-id: bc34b3d7c79a8f9157729c4cf0486507c3c15ddf
This commit is contained in:
committed by
Facebook Github Bot
parent
f75d47c915
commit
e7e1a93d8a
@@ -753,11 +753,14 @@ UIImage *__nullable RCTImageFromLocalAssetURL(NSURL *imageURL)
|
||||
|
||||
if (!image) {
|
||||
// Attempt to load from the file system
|
||||
NSString *filePath = [NSString stringWithUTF8String:[imageURL fileSystemRepresentation]];
|
||||
if (filePath.pathExtension.length == 0) {
|
||||
filePath = [filePath stringByAppendingPathExtension:@"png"];
|
||||
const char* fileSystemCString = [imageURL fileSystemRepresentation];
|
||||
if (fileSystemCString != NULL) {
|
||||
NSString *filePath = [NSString stringWithUTF8String:fileSystemCString];
|
||||
if (filePath.pathExtension.length == 0) {
|
||||
filePath = [filePath stringByAppendingPathExtension:@"png"];
|
||||
}
|
||||
image = [UIImage imageWithContentsOfFile:filePath];
|
||||
}
|
||||
image = [UIImage imageWithContentsOfFile:filePath];
|
||||
}
|
||||
|
||||
if (!image && !bundle) {
|
||||
|
||||
Reference in New Issue
Block a user