Access downloaded pdf file path in HTML5 file system and display it in webview

421 views Asked by At

In my chrome app, I am using HTML5 file system to save the pdf files to sand box.Downloading is working fine.But how do i access that downloaded file path? I want to give that path as webview source.

2

There are 2 answers

4
Ben Wells On BEST ANSWER

The best way, if it works, would be to use a filesystem URL. To get this use FileEntry.toURL

These don't work on external files (i.e. files that come from chrome.fileSystem.chooseEntry and are outside the app's sandbox) but should work for files in the app's sandbox.

Note, I am referring to filesystem:// urls not file://urls, which won't work as Marc Rochkind has pointed out in his answer.

Disclaimer: I haven't tested this, but I believe it should work.

0
Marc Rochkind On

You need to get the contents of the PDF into a data URL. See my answer to this question:

Download external pdf files to chrome packaged app's file system