Display a PDF downloaded through FileSystem to the documentDirectory

I am trying to figure out a way to do this without ejecting. I’ve tried using a WebView

<WebView source={{uri: "file:///..."}} />

But nothing displays. Are there permissions issues? Is it an IOS simulator problem? Is it not possible? I’m getting no errors from the system. Please let me know your thoughts, I’ve spent hours researching this with no luck. I’m hoping with your expertise we can figure out the best approach.

Thanks so much in advance.

Update: This is working for IOS, but not for android. Does anyone know if this is possible for android? I read that Lollipop+ webviews should support PDFs. Is this an android file access problem? Thanks!

Hi @jogillesp! Where are you storing this file on Android? It could definitely be a permission issue depending on where the file is stored.

I’m using the Expo FileSystem module to download the file. The module provides a constant with the path where it stores the file:


For android, it contains this value:

/data/user/0/host.exp.exponent/files/ExperienceData/%2540jogillesp%252Foo/ for android.

Here is my webview:

        source={{uri: "file:///data/user/0/host.exp.exponent/files/ExperienceData/%2540jogillesp%252Foo/pdfs/26.pdf"}}

It seems file:///data/user/0/host.exp.exponent/files/ExperienceData/%2540jogillesp%252Foo/pdfs/26.pdf
doesn’t actually exist on my Mac. Where is the file being stored, or is it being stored? FileSystem throws no errors, and seems to download fine.

Anyone have any ideas? Thanks

The file exists on your Android device (virtual or physical). There are some tools to inspect the files on Android devices that might let you browse to that path if you have the right permissions. You could also use the FileSystem module to verify the existence of the file (ex: try reading it back). If the WebView won’t display the file and it exists, the error might be related to permissions as suggested above, and you’d have to dive more into Android’s implementation to see what the root cause could be.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.