# get()

Canonical URL: https://developers.iagenify.com/es/sdk/ref/storage/get/
Language: es

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

Un almacenamiento, listo para usar. Sin argumento, la cuenta por defecto.

Status: GET /api/storage/:id · free · null, never a throw

## Parámetros {#parameters}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `id` | string |  | Deja fuera el almacenamiento por defecto de la cuenta. |

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

## Responde nulo en lugar de tirar {#null}

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».

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

if (!storage) {
  throw new Error("that storage is not on this account");
}
```

## Esto, o getStorage() {#versus}

|  | 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 {#doing}

```javascript
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();
```

> **los archivos y terminales existen sólo en un ordenador**
>
> 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.

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

## Lo que lleva {#fields}

| 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.

- [Almacenamiento conectado](/es/sdk/ref/connected-storage): Todo en el objeto esto vuelve.
- [api.getStorage()](/es/sdk/ref/iagenify/get-storage): El valor predeterminado, como cuatro campos simples.

```python
target = api.storage.get()                # the default
one = api.storage.get(id=storage_id)      # a particular one
```

```python
storage = api.storage.get(id=storage_id)

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

```python
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()
```

```python
if storage.type == "filesystem":
    storage.files.list()
else:
    storage.run(action="objects")
```
