I need a open local file feature in my website, so I use File System Access API in my code. when the file opened from local is edited by my web and need to save to original file. I found it has no permission. Therefore, I find the way to request filehandle permission like below:
async function verifyPermission(fileHandle: any, readWrite: boolean) {
const options = {
mode: 'readwrite',
};
let isPermit = false;
// Check if permission was already granted. If so, return true.
if ((await fileHandle.queryPermission(options)) === 'granted') {
isPermit = true;
}
if ((await fileHandle.requestPermission(options)) === 'granted') {
isPermit = true;
}
return isPermit;
}
but when i execute to fileHandle.requestPermission(options)
it console error
Uncaught (in promise) DOMException: User activation is required to request permissions.
What I am missing? thank you QQ