Back to Content

StorageAccessHandle: getDirectory() method

files/en-us/web/api/storageaccesshandle/getdirectory/index.md

latest1.0 KB
Original Source

{{APIRef("Storage Access API")}}

[!NOTE] See {{domxref("StorageManager.getDirectory()")}} to understand usage.

Syntax

js-nolint
getDirectory()

Parameters

None.

Return value

A {{jsxref("Promise")}} that fulfills with an unpartitioned {{domxref("FileSystemDirectoryHandle")}} object.

Exceptions

  • SecurityError {{domxref("DomException")}}
    • : Thrown if access was not granted.

See {{domxref("StorageManager.getDirectory()")}}

Examples

js
document.requestStorageAccess({ getDirectory: true }).then(
  (handle) => {
    console.log("getDirectory access granted");
    await handle.getDirectory();
  },
  () => {
    console.log("getDirectory access denied");
  },
);

[!NOTE] See Using the Storage Access API for a more complete example.

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also