Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

308
Views
FileSystemHandle.requestPermission DOMException: User activation is required to request permissions

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

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can always query a file's permissions, but requesting requires a user gesture (like a button to be clicked). This is outlined in the spec (emphasis mine):

If the state of the read permission of this handle is anything other than "prompt", this will return that state directly. If it is "prompt" however, user activation is needed and this will show a confirmation prompt to the user. The new read permission state is then returned, depending on the user’s response to the prompt.

You need to decouple querying and requesting permissions in your implementation.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!