Retorno
{
id: "…",
label: "Object Storage",
type: "object",
tier: "free"
}{
"id": "…",
"label": "Object Storage",
"type": "object",
"tier": "free",
}idstringQuale tu passas come storageId a tutto censièrsèe.
labelstringIl nome display. Tua a cambiar, non a igual.
typestringQue tipo di stoccaj is — vee in basso. Questo è il campo a ramificare.
tierstringL'armorzament de nivel.
Ogni conto è creato con il suo stoccaggio de objetos, e che è quello portando la bandera predefinita — quindi questo appello normalmente risponde con un lugar onde si può realmente scriver.
e por què decide tutto
| tipo | Descrição | Fichiers live |
|---|---|---|
| objete | Un stoccaggio d'objet: bytes sotto chiues. | Na conta |
| Base de dados | Una base di dati connessa, let e scrit a travers run(). | Na conta |
| sistema de fiches | Un computer. I suoi files sono su que la macchina. | Sull'octek, sotto ~/.iagenify/files |
| telefono | Un telefono registrato. I suoi files sono in suo browser. | In quel browser |
| Navegatore | Un negozio de browser. | In quel browser |
Salvare a un a través del server è negat con storage_is_local — non perché ha fallit, ma perché quei files solo existient sul dispositivo. Legga e scrie dal dispositivo, attraverso il SDK correndo là o attraverso un ponte.
Le tre cose che pots realmente desiderare
await api.getStorage(); // the default, as plain fields
const target = await api.storage.get(); // the default, with run() and files on it
const one = await api.storage.get({ id }); // a particular storage
const all = await api.storage.list(); // every storage on the accountapi.get_storage() # the default, as plain fields
target = api.storage.get() # the default, with run() and files on it
one = api.storage.get(id=storage_id) # a particular storage
every = api.storage.list() # every storage on the accountQuattro campi, senza metodi. Usare questo appello per mostrar qual storage è il predefinit; use api.storage.get() quando si intende fare algo con esso.
api.storage.get() lege la stessa rota e lee un ConnectStorage — l'objeto que porta run(), e files quando il storage è una máquina.
Que la bandera predefinita decide realmente
- Un salvat con no
storageIdva là. - È una proprietà del conto, non del cliente: cambiare macchine non lo cambia.
- Exactamente un stoccaggio attivo lo porta. Eliminare quel stoccaggio e il drapeau è predato a un altro — non è mai lasciato nulcun lugar.
- Fa no decide dove lavora un agente. Un agente lavora sul dispositivo che è stato dato, e che è una scelta separata.
Quando è null
null significa che nessun storage activo porta la bandeira. Desde la cancellazione del porta-bandeira , un null è abbastanza inusual da guardare, e non retest.
const target = await api.getStorage();
if (!target) {
const all = await api.storage.list();
throw new Error(`no default storage; ${all.length} storage(s) on the account`);
}
if (target.type === "filesystem" || target.type === "phone") {
// Saving here through the server will be refused: this device keeps its own files.
}target = api.get_storage()
if target is None:
every = api.storage.list()
raise RuntimeError(f"no default storage; {len(every)} storage(s) on the account")
if target["type"] in ("filesystem", "phone"):
pass # Saving here through the server will be refused: this device keeps its own files.Scrivendo a un stoccaggio nominato in lugar
Se basare sul predefinit è agradable per un stoccaj e fragile para varios: la bandera pode mover. Quando un processo deve sempre scriver al medesimo lugar, lo resolver con label una vez e conservar l'identit.
const all = await api.storage.list();
const archive = all.find((s) => s.label === "Archive" && s.type === "object");
if (!archive) throw new Error("the Archive storage is not connected");
// Keep archive.id in configuration, and pass it explicitly from then on.archive = next((s for s in api.storage.list() if s.label == "Archive" and s.type == "object"), None)
if archive is None:
raise RuntimeError("the Archive storage is not connected")
# Keep archive.id in configuration, and pass it explicitly from then on.