I have a very simple function that opens a file as shown in the example on mozilla
// fileHandle is a FileSystemFileHandle
// withWrite is a boolean set to true if write
async function verifyPermission(fileHandle, withWrite) {
const opts = {};
if (withWrite) {
opts.mode = 'readwrite';
}
// Check if we already have permission, if so, return true.
if (await fileHandle.queryPermission(opts) === 'granted') {
return true;
}
// Request permission to the file, if the user grants permission, return true.
if (await fileHandle.requestPermission(opts) === 'granted') {
return true;
}
// The user did not grant permission, return false.
return false;
}
but I keep getting an error saying that file.queryPermission is not a function. Here's my code:
let file = await window.showOpenFilePicker();
console.log(file.queryPermission({ mode: 'readwrite' }));
I've also tried putting the console.log in a .then but had the same result.