Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

311
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda