# 使用

Canonical URL: https://developers.iagenify.com/zh/sdk/ref/connected-storage/run/usage/
Language: zh

`storage.run({ action: "usage" })`

存储空间要花多少。 写之前的读数因缺少空间而失效 。

Status: any storage · free · a reading

```javascript
await storage.run({ action: "usage" });
```

## 为何在写之前问 {#why}

计划空间的写作被拒绝 `quota_exceeded`读和删除工作持续进行——不对称是故意的,所以你总是可以获取数据,腾出空间——但一个在批量中途失败的写作,将让你去研究落地的东西。

```javascript
const before = await storage.run({ action: "usage" });

// Write in batches, and stop on the first refusal rather than pushing through
for (const batch of batches) {
  try {
    await storage.run({ action: "insert", collection, documents: JSON.stringify(batch) });
  } catch (err) {
    if (err.code === "quota_exceeded") break;
    throw err;
  }
}
```

## 此存储或账户 {#account}

| 问题问题(问题) 问题 | 询问询问 |
| --- | --- |
| 这个有多满? | 运行( { 动作: “ 使用 ” ) } |
| 该计划在服务方面提供了什么? | api.cloud.usage() |
| 哪个文件占用空间? | api.files.list(),并按大小排序 |

账户一级的观点 告诉你购买空间是否有用, 因为那是计划 的津贴生命。

- [api.cloud.usage()](/zh/sdk/ref/cloud/usage): 服务于服务服务
- [run()](/zh/sdk/ref/connected-storage/run): 行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动,行动

```python
storage.run(action="usage")
```

```python
import json
from iagenify import IaGenifyError

before = storage.run(action="usage")

# Write in batches, and stop on the first refusal rather than pushing through
for batch in batches:
    try:
        storage.run(action="insert", collection=collection, documents=json.dumps(batch))
    except IaGenifyError as error:
        if error.code == "quota_exceeded":
            break
        raise
```
