Parámetros
idstringDeja fuera el almacenamiento por defecto de la cuenta.
const target = await api.storage.get(); // the default
const one = await api.storage.get({ id }); // a particular onetarget = api.storage.get() # the default
one = api.storage.get(id=storage_id) # a particular oneResponde nulo en lugar de tirar
Un identificador desconocido, uno mal formado, o uno que pertenece a otro cuenta todos dan null. Así que la comprobación es una prueba de valor, no una prueba / captura — y null nunca significa «es de otra persona».
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")Esto, o getStorage()
| api.storage.get() | api.getStorage() | |
|---|---|---|
| Da | Un almacenamiento conectado, con métodos | Cuatro campos llanos |
| Úsalo para | leer, escribir, listar archivos | mostrar cuál es el predeterminado |
| Toma una identificación | Sí | no — siempre el valor predeterminado |
Lo que puedes hacer con lo que vuelve
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()Alcanzarlos en cualquier otra cosa lanza storage_not_local, y en un teléfono storage_is_phone — sus archivos están en su navegador. Tipo de prueba antes de llegar.
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")Lo que lleva
| Campo | Es |
|---|---|
| id · etiqueta | Identidad y nombre de la pantalla. |
| tipo | sistema de archivos · teléfono · navegador · base de datos · objeto |
| proveedor · gestionadoPor | ¿Qué hay detrás de él, y quién lo opera. |
| servicio | nosql · sql · object on an IaGenify Cloud storage; null otherwise. |
| esDefault | Si un salvo sin objetivo va aquí. |
| machineId · nombre de máquina · deviceId | En un dispositivo: cuál. |
Nada aquí lleva una credencial: lo que usted suministró en la conexión es utilizado por el servidor y no devuelto.