DocumentPicker.open() from Files.app > On My iPhone/iPad

I have a simple Script which will display a HTML page by choosing the file with DocumentPicker.open(…)

const webView = new WebView()

var filepth = await DocumentPicker.open(['public.html'])

 await webView.loadFile(filepth[0].toString(), null, true)
await webView.present(true)

This works no problem when opening from anywhere in the iCloud Drive including the Scriptable Folder.

But when I navigate to On My iPhone, I can select a file but all I then get is the scripts progress bar spinning.

Is it possible to do this or am I hitting a permission restriction or something ?.

Many thanks.

Maybe it is a restriction as you’ve mentioned. You could try to copy the file first to the local Scriptable cache/temporary folder and open it from there. After closing the WebView you could then delete the temporary file.

Thanks but I am not sure of which cache folder you are referring to ?

I mean this:

let fm = FileManager.local();
let basePath = fm.cacheDirectory();
// or
let basePath = fm.temporaryDirectory();

I will have a look at those.
I was using FileManger before to access iCloud but realised I could use the picker instead which gave more latitude.

I will look at a way to incorporate FileManger but the copy part will not work for my use case.
The Html file points to a special directory that has all its runtime code and assets, copping all of that would not be a good idea in practice.

Thanks.

Ah, that might be the reason. iOS allows Scriptable access to the HTML file, but not the others. Scriptable is trying to access them, but can’t and therefore it probably hangs somewhere. It probably works in iCloud Drive, because the restrictions aren’t that strict there (only the user has copied the files there and there is no app data), whereas in the local file section there might be other data the user has no control of and therefore it is more restricted.

This is only an assumption. I might be totally wrong.

Did a quick test with a simple html file no the files assets or directories.

Same thing.

I think it may be the operation is just not allowed here. Which not sure makes sense since we can access the area with the DocumentPicker in the first place?