FileSystemHandle: requestPermission() method
The requestPermission()
method of the FileSystemHandle
interface requests read or readwrite permissions for the file handle.
Syntax
requestPermission(fileSystemHandlePermissionDescriptor)
Parameters
-
FileSystemHandlePermissionDescriptor Optional
-
An object which specifies the permission mode to query for. Options are as follows:
'mode'
: Can be either 'read'
or 'readwrite'
.
Return value
PermissionStatus.state
which is one of 'granted'
, 'denied'
or 'prompt'
.
Exceptions
-
TypeError
-
Thrown if no parameter is specified or the mode
is not that of 'read'
or 'readwrite'
Examples
The following asynchronous function requests permissions if they have not been granted.
async function verifyPermission(fileHandle, withWrite) {
const opts = {};
if (withWrite) {
opts.mode = "readwrite";
}
if ((await fileHandle.queryPermission(opts)) === "granted") {
return true;
}
if ((await fileHandle.requestPermission(opts)) === "granted") {
return true;
}
return false;
}
Specifications
Browser compatibility
|
Desktop |
Mobile |
|
Chrome |
Edge |
Firefox |
Internet Explorer |
Opera |
Safari |
WebView Android |
Chrome Android |
Firefox for Android |
Opera Android |
Safari on IOS |
Samsung Internet |
requestPermission |
86 |
86 |
No |
No |
72 |
No |
No |
86 |
No |
61 |
No |
14.0 |
See also