Image doesn't render local source (path with no extension name)
See original GitHub issueš Bug Report
// write image to local path(iOS native code)
NSString *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES).firstObject;
NSString *filePath = [path stringByAppendingPathComponent:[NSString stringWithFormat:@"image"]];
[UIImagePNGRepresentation(image) writeToFile:filePath atomically:YES]
// under iOS (it works great)
[UIImage imageWithContentsOfFile: filePath];
// under react native (Could not find image filePath)
<Image source={{ uri: filePath }} />
// If the filePath with extension name it works on both
NSString *filePath = [path stringByAppendingPathComponent:[NSString stringWithFormat:@"image.png"]];
[UIImagePNGRepresentation(image) writeToFile:filePath atomically:YES]
Reason
Reason is the file has no extension name when write to path! It doesnāt master under iOS, not work under React native!
Code Example & Reproduce
Github react-native-image-no-extension
Why I need to render image from local source
My project is using a iOS native IM framework. The framework save image to the local path without extension. Now I build chat ui by react native, so I must be able to render the image!
Environment
React Native Environment Info: System: OS: macOS 10.14.3 CPU: (4) x64 IntelĀ® Coreā¢ i5-7360U CPU @ 2.30GHz Memory: 93.95 MB / 8.00 GB Shell: 5.3 - /bin/zsh Binaries: Node: 8.11.1 - /usr/local/bin/node Yarn: yarn install v0.22.0 [1/4] Resolving packagesā¦ [2/4] Fetching packagesā¦ [3/4] Linking dependenciesā¦ [4/4] Building fresh packagesā¦ success Saved lockfile. Done in 14.56s. - /usr/local/bin/yarn npm: 6.7.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1 Android SDK: API Levels: 23, 26, 27, 28 Build Tools: 27.0.3, 28.0.3 System Images: android-28 | Intel x86 Atom_64 IDEs: Android Studio: 3.2 AI-181.5540.7.32.5056338 Xcode: 10.1/10B61 - /usr/bin/xcodebuild npmPackages: react: 16.8.4 => 16.8.4 react-native: 0.59.0 => 0.59.0 npmGlobalPackages: create-react-native-app: 1.0.0 react-native-cli: 2.0.1 react-native-git-upgrade: 0.2.7
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (3 by maintainers)
Top GitHub Comments
@zhongwuzw #23864 works! @react-native-bot
fixed in https://github.com/facebook/react-native/commit/e40a76715a11b1465c10076f975ff7335c84cf30