puter.fs.unshare()This method withdraws a user's access to a file or directory.
What an app can share. An app never gets more reach than it was given. It can share its own AppData, and files the user specifically granted it, at up to the level of access it holds itself — so an app with read access can grant read, and nothing more. Files its user owns but never handed to the app stay out of reach, and
listShared()shows an app only the shares it can reach. Shares an app creates are attributed to the user and carryissuedByApp, so the owner can tell them apart ingetShares()— and those are the only ones an app can list or withdraw on an item. Opening an item to anyone with the link is the owner's own call, never an app's.
puter.fs.unshare(path, recipient)
puter.fs.unshare(options)
path (String) (required)
The path to the file or directory. If path is not absolute, it will be resolved relative to the app's root directory.
recipient (String | Object) (required)
Whose access to withdraw. A string containing @ is treated as an email address, and any other string as a username.
Pass yourself to leave a share someone else gave you. Pass { team: uid } to withdraw a team's access, or { anyone: true } to stop sharing with anyone with the link — the latter is the owner's call, in person, as opening it was.
options (Object) (optional)
An object with the following properties:
path (String) - The item. Required when passing options as the only argument.uid (String) - The item, by UID. Can be used instead of path.recipient (String | Object) - Whose access to withdraw.A Promise that resolves to { revoked }, where revoked is how many grants were actually removed. It is 0 when there was nothing to withdraw, which is not an error.
revoked: 0 to it. Leaving a share yourself still works through an app, since that is your own access to drop.An item's owner cannot be removed from their own item.
Withdrawing someone's access also withdraws whatever they re-shared of that item — unless their authority to grant does not rest on what you took back. Someone who still holds manage here from another person, from a team, or from a folder above keeps what they granted; it was never yours to withdraw.
Passing an email address that was invited but has not yet joined cancels the invitation. Nothing was granted, so nothing is revoked from anyone — the pending share simply stops waiting.
Stop sharing a file
<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<script>
(async () => {
await puter.fs.write('report.txt', 'Quarterly numbers');
await puter.fs.share('report.txt', 'friend@example.com');
const result = await puter.fs.unshare('report.txt', 'friend@example.com');
puter.print(`Removed ${result.revoked} share(s)<br>`);
})()
</script>
</body>
</html>
Leave a share someone gave you
const me = await puter.auth.getUser();
await puter.fs.unshare('/alice/report.txt', me.username);
puter.fs.share() - Grant accessputer.fs.getShares() - See who can reach an item