puter.fs.space()

Websites Puter Apps Node.js Workers

Returns the storage capacity and usage of the current user.

Syntax

puter.fs.space()

Parameters

None.

Return value

A Promise that resolves to a SpaceInfo object with these properties:

  • capacity (Number): The total storage capacity available to the user, in bytes.
  • used (Number): The amount of storage the user has used, in bytes.

Examples

Show how much storage the user has used

<html>
<body>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        (async () => {
            const { used, capacity } = await puter.fs.space();
            const toMB = (bytes) => (bytes / 1024 / 1024).toFixed(1);
            puter.print(`Used ${toMB(used)} MB of ${toMB(capacity)} MB`);
        })();
    </script>
</body>
</html>