puter.perms.requestWriteDocuments()Request write access to the user's Documents folder. If the user has already granted this permission the user will not be prompted and the path will be returned. If the user grants permission the path will be returned. If the user does not allow access undefined will be returned.
puter.perms.requestWriteDocuments()
None
A Promise that resolves to:
string - The Documents folder path if permission is grantedundefined - If permission is denied<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<button id="request-documents">Request Documents Write Access</button>
<script>
document.getElementById('request-documents').addEventListener('click', async () => {
const documentsPath = await puter.perms.requestWriteDocuments();
if (documentsPath) {
puter.print(`Documents path: ${documentsPath}`);
// Now you can write files to the Documents folder
await puter.fs.write(`${documentsPath}/my-document.txt`, 'Hello from Documents!');
puter.print('File written to Documents folder');
} else {
puter.print('Documents write access denied');
}
});
</script>
</body>
</html>