On iOS, No File is Displayed
See original GitHub issueOn iOS, no file is displayed. The screen only displays the file name and its size (screenshoft below). On Android, it works perfectly fine! Using macOS’s Finder, I can find the file on the disk. However, I am not sure why it does not display on the screen.
react-native: 0.64.2
react-native-file-viewer: 2.1.4
react-native-fs: 2.18.0
simulator: iOS 14.4 - iPhone 12
const ext = URI.substring(URI.lastIndexOf(".")); // Get the extension of the file.
const localFile = `${RNFS.DocumentDirectoryPath}/temporaryfile${ext}`;
RNFS.downloadFile({ fromUrl: URI, toFile: localFile }).promise
.then(() => {
FileViewer.open(localFile, {showOpenWithDialog: true, showAppsSuggestions: true, })
.then(() => {
console.log("_dislayFile - FileViewer - success", " - localFile:", localFile);
// The execution reaches here, and the result of console.log() follows. I can find the file on the disk.
// -> result: /Users/macbilal/Library/Developer/CoreSimulator/Devices/A2614BF5-7312-4DB5-917F-9F74311B95BE/data/Containers/Data/Application/4B45536B-2583-45AC-8C2B-FA47BC558236/Documents/temporaryfile.jpg?alt=media&token=ec9d814a-27d5-4283-9ae1-d4950e43489f
})
.catch(error => {
console.error("_dislayFile - FileViewer - error:", error, );
});
})
.catch(error => {
console.error("CertDetails - downloadFile - error:", error, "localFile:", localFile, );
});

Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Nothing appears in files app in iOS 11 on iPad air2
Usually the Files app works fine and it integrates with other apps (eg Pages) as expected. Every few days, though, it stops displaying...
Read more >On My iPhone/iPad Option Not Showing/Missing in Files App ...
Launch the Files app and tap Edit at the top-right corner. · Turn the toggle for On My iPhone to the ON position....
Read more >Fix On My iPhone or On My iPad Folder Not Showing/Missing ...
Steps for Enable Missing “On My iPhone” or “On My iPad” Folder in Files app · On my iPhone or iPad option not...
Read more >How to Fix Files App Not Working on iPhone - Guiding Tech
On the Settings screen, tap Cellular Data, scroll down, and then check that the switch next to Files is set to On. If...
Read more >[Solved] iPhone Not Showing in Windows File Explorer
Download Free FoneTool Now (former name: AOMEI MBackupper) https://www.aomeitech.com/llyy/download/fonetool.html Related Reference ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@vinzscam You are a genius!!! Your code fixed the problem.
However, I suspect this problem won’t occur on an actual iOS device. Anyway, to make sure the extension extraction code does NOT fail when the file name does not have a (?), I added a bit more checking to it. Here is the final version, should anybody else be interested.
Hi @Bilal-Abdeen,
the issue seems to be related on your function used for retrieving the extensions from the uri. On Android you are able to open the file because specifying the file’s extension as part of the saved file name is not required. On iOS this is a strict requirement: So, if you are downloading a jpg file, the file needs to be saved as
something.jpg. Looking at your logs, you are saving the file astemporaryfile.jpg?alt=media&token=ec9d814a-27d5-4283-9ae1-d4950e43489f, which isn’t recognized from iOS as.jpg.In your case instead of invoking
const ext = URI.substring(URI.lastIndexOf("."));the following should do the trick: