Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

309
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda