# get()

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

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

一个存储器,准备使用 毫无争议,账户违约

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

## 参数 {#parameters}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `id` | string |  | 哪个储藏室 留到账户违约时再处理 |

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

## 空投,而不是扔掉 {#null}

未知身份、错误身份或属于另一个账户的账户 `null`。因此,检查是一个价值测试,而不是尝试/catch -和 `null` 绝不意味着“这是别人的”

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

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

## 这个, 或者获得标准() {#versus}

|  | api.storage.get() | api.getStorage() |
| --- | --- | --- |
| 给给给 | A 连接系统,使用方法 | 四平原字段 |
| 使用它 | 读、写、写、列出文件 | 显示哪个是默认值 |
| 取取 ID | 否 是 | 没有 - 总是默认 |

## 回来后你能做什么 {#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();
```

> **仅存在于计算机中的文件和终端文件**
>
> 或用任何物物去达到他们, storage_not_local,在手机上 storage_is_phone ——其文件在浏览器中。在您到达之前测试类型。

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

## 随它携带的 {#fields}

| 字段 | 是 |
| --- | --- |
| ID 标签 ID = 标签 | 和显示名称。 |
| 类型类型类型 | · 电话 · 浏览器 · 数据库 · 对象 |
| 提供商 管理 | 背后的是什么 是谁在操作它 |
| 服务 | 对象在 IaGenify 云储存;否则无效。 |
| 是一个“默认” | 是否在此保存无目标的保存 。 |
| 机器 Id · 主机名 · 设备IDd | 在一个装置上:哪一个。 |

这里没有带有证书的东西:您在连接时提供的是服务器使用的,没有交还。

- [连接连接的系统](/zh/sdk/ref/connected-storage): 物体上的一切 返回。
- [api.getStorage()](/zh/sdk/ref/iagenify/get-storage): 默认值, 以四个平坦字段的形式 。

```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")
```
