This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is available in Web Workers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The queryPermission() method of the FileSystemHandle interface queries the current permission state of the current handle.
queryPermission(descriptor)
descriptor OptionalAn object which specifies the permission mode to query for. Options are as follows:
'mode' OptionalCan be either 'read', 'write', or 'readwrite'.
A Promise that resolves with PermissionStatus.state which is one of 'granted', 'denied' or 'prompt'. It may also reject with one of the exceptions below.
If this resolves with "prompt", the website will have to call requestPermission() before any operations on the handle can be done. If this resolves with "denied" any operations will reject. Usually handles returned by the local file system handle factories will initially resolves with "granted" for their read permission state. However, other than through the user revoking permission, a handle retrieved from IndexedDB is also likely to resolves with "prompt".
TypeErrorThrown if mode is specified with a value other than 'read', 'write', or 'readwrite'
The following asynchronous function returns true if user has granted read or readwrite permissions to the file handle. Permission is requested if not.
// 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;
}
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
queryPermission |
86 | 86 | No | 72 | No | 109 | No | 74 | No | 21.0 | 109 | No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/queryPermission