api.storage

get()

api.storage.get({ id }) → Promise<ConnectedStorage | null>

One storage, ready to use. With no argument, the account's default.

GET /api/storage/:idfreenull, never a throw
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

Parameters

idstring

Which storage. Leave it out for the account's default.

const target = await api.storage.get();            // the default
const one = await api.storage.get({ id });         // a particular one
target = api.storage.get()                # the default
one = api.storage.get(id=storage_id)      # a particular one

It answers null rather than throwing

An unknown id, a malformed one, or one belonging to another account all give null. So the check is a value test, not a try/catch — and null never means « it is someone else's ».

const storage = await api.storage.get({ id });

if (!storage) {
  throw new Error("that storage is not on this account");
}
storage = api.storage.get(id=storage_id)

if storage is None:
    raise LookupError("that storage is not on this account")

This, or getStorage()

api.storage.get()api.getStorage()
GivesA ConnectedStorage, with methodsFour plain fields
Use it toread, write, list filesshow which one is the default
Takes an idyesno — always the default

What you can do with what comes back

const storage = await api.storage.get({ id });

// Any storage: read and write through run()
await storage.run({ action: "collections" });

// A computer only: its own files, on that machine
const pc = await api.storage.get({ id: computerId });
await pc.files.list();
storage = api.storage.get(id=storage_id)

# Any storage: read and write through run()
storage.run(action="collections")

# A computer only: its own files, on that machine
pc = api.storage.get(id=computer_id)
pc.files.list()
files and terminals exist only on a computer

Reaching for them on anything else throws storage_not_local, and on a phone storage_is_phone — its files are in its browser. Test type before you reach.

if (storage.type === "filesystem") {
  await storage.files.list();
} else {
  await storage.run({ action: "objects" });
}
if storage.type == "filesystem":
    storage.files.list()
else:
    storage.run(action="objects")

What it carries

FieldIs
id · labelIdentity, and the display name.
typefilesystem · phone · browser · database · object
provider · managedByWhat is behind it, and who operates it.
servicenosql · sql · object on an IaGenify Cloud storage; null otherwise.
isDefaultWhether a save with no target goes here.
machineId · hostname · deviceIdOn a device: which one.

Nothing here carries a credential: what you supplied at connection is used by the server and not handed back.