Closed steveruizok closed 2 years ago
You might be missing the permissions step. Here's a working code sample of one of my apps:
const checkPermissions = async (handle) => {
const options = { mode: 'read' };
if ((await handle.queryPermission(options)) === 'granted') {
return true;
}
if ((await handle.requestPermission(options)) === 'granted') {
return true;
}
return false;
};
// …snip…
try {
// Start where the user left off.
// (This uses https://github.com/jakearchibald/idb-keyval
// for convenience.)
const handle = await get(FILE_HANDLE);
if (handle && (await checkPermissions(handle))) {
const file = await handle.getFile();
// …snip…
}
} catch (err) {
console.error(err.name, err.message);
await del(FILE_HANDLE);
}
// …snip…
Does this work for you?
Works! Though strangely if I set the mode to readwrite
the permissions pop-up comes up twice.
Great to hear! This may be a temporary thing, the final permission flow may still change. Closing the Issue then.
Hi, I'm trying to restore a
FileHandle
after refreshing a page where a handle had been previously set. I am able to save and load the handle from indexdb as described in this StackOverflow question, however thefileSave
method does not appear to accept it.Here's the chain of events.
I would expect number 8 to go to step number 5, rather than step number 2.
I've checked also on Excalidraw, the same behaviour appears to be happening there.