这里没有缓存的东西:每个存储的大小都是记录下来的,上限从您询问的计划和附加值中进行重新计算。两个大写字母的两边都打出两个不同的答案。
返回值
{
pack: "go", // "free" | "go" | "starter"
nosql: {
usedBytes: 8_720_384,
includedBytes: 1_048_576_000, // ceiling × how many the plan allows
quotaBytes: 1_048_576_000, // included + the add-on pool
perBaseBytes: 524_288_000, // the ceiling of ONE storage
bases: 2,
maxBases: 2,
overQuota: false,
available: true,
storages: [
{ id: "…", label: "App data", usedBytes: 8_716_288, quotaBytes: 524_288_000, overQuota: false },
{ id: "…", label: "Reporting", usedBytes: 4_096, quotaBytes: 524_288_000, overQuota: false }
]
},
sql: { /* same shape */ },
object: { /* same shape */ , hostingBytes: 2_310_144 },
addons: {
databaseGb: 0,
objectGb: 1,
renewsAt: "2026-11-02T10:14:00.000Z",
lapsed: false,
monthlyCredits: 200,
pricePerGb: { database: 100, object: 200 }
}
}{
"pack": "go", # "free" | "go" | "starter"
"nosql": {
"usedBytes": 8_720_384,
"includedBytes": 1_048_576_000, # ceiling × how many the plan allows
"quotaBytes": 1_048_576_000, # included + the add-on pool
"perBaseBytes": 524_288_000, # the ceiling of ONE storage
"bases": 2,
"maxBases": 2,
"overQuota": False,
"available": True,
"storages": [
{"id": "…", "label": "App data", "usedBytes": 8_716_288, "quotaBytes": 524_288_000, "overQuota": False},
{"id": "…", "label": "Reporting", "usedBytes": 4_096, "quotaBytes": 524_288_000, "overQuota": False},
],
},
"sql": {}, # same shape as nosql
"object": {"hostingBytes": 2_310_144}, # same shape as nosql, plus hostingBytes
"addons": {
"databaseGb": 0,
"objectGb": 1,
"renewsAt": "2026-11-02T10:14:00.000Z",
"lapsed": False,
"monthlyCredits": 200,
"pricePerGb": {"database": 100, "object": 200},
},
}一个服务区块, 字段按字段分列
usedBytesinteger服务所拥有的一切 object 其 年 日, 其 包括 hostingBytes.
includedBytesintegerperBaseBytes × maxBases - 计划在增加任何额外费用之前提供什么。
quotaBytesintegerincludedBytes 加本项服务可用的额外集合。
perBaseBytesinteger单一储存的最高限度。 作者的写作是依据这个数字来判断的。
basesinteger有多少储存的这种服务存在。
maxBasesinteger计划允许多少人 bases 表示另一条被拒绝。
overQuotaboolean当总通过时真实 quotaBytes 或 任何储存都超过自己的上限。
availableboolean是否现在可以使用此服务 。
storagesarray每个储存一个条目: id, label, usedBytes, quotaBytes, overQuota.
要显示的编号, 以及要根据
服务总量中的进展栏可以坐以40%, 而插入被拒绝, 因为一个存储已满 。 显示每个存储数字, 用户将在哪里写入, 并保留总和以保存摘要 。
function roomFor(usage, storage) {
const service = usage[storage.service]; // "nosql" | "sql" | "object"
const base = service.storages.find((s) => s.id === storage.id);
return base ? Math.max(0, base.quotaBytes - base.usedBytes) : null;
}def room_for(usage, storage):
service = usage[storage.service] # "nosql" | "sql" | "object"
base = next((s for s in service["storages"] if s["id"] == storage.id), None)
return max(0, base["quotaBytes"] - base["usedBytes"]) if base else None配额超过配额有两个原因
当服务总额通过账户时,情况确实如此。 和 当一个储存单位超过自己的上限时——第二个是情况如此,一个总数永远无法透露。阅读每个储存单位的旗帜就会知道是哪个。
仅对对象的主机主机Bytes
账户主机在网上保留什么。 它在计算每个存储量之前从目标上限中移除, 所以部署明显减少了留给文件的房间—— 每一个文件一个号码 IaGenify 保存账户。
添加的区块
databaseGb · objectGbinteger以每加一加一计的Gigabitte目前持有的 。
renewsAtstring|null期限结束时,之前购买的物品按比例分配。
lapsedboolean无法支付续期:池子暂停使用,上限恢复到计划。
monthlyCreditsinteger额外费用每期都计算多少,加起来合在一起。
pricePerGbobject{ database: 100, object: 200 } - 每一时期每千兆字节的信用额。
暂停的附加内容将天花板重新移下,这样一个舒适的储存室就可以在不写任何文字的情况下全部填满。 池子被重新研究,一旦积分到位,就会回来。
值得做两件事
// 1. Before creating a storage — is one allowed at all?
const usage = await api.cloud.usage();
if (usage.nosql.bases >= usage.nosql.maxBases) {
// api.storage.create() would answer cloud_storage_limit
}
// 2. Before a large write — will it fit?
const bytes = Buffer.byteLength(payload);
const left = usage.object.storages[0].quotaBytes - usage.object.storages[0].usedBytes;
if (bytes > left) {
// Free something, or api.cloud.addons.buy({ service: "object", gb: 1 })
}# 1. Before creating a storage — is one allowed at all?
usage = api.cloud.usage()
if usage["nosql"]["bases"] >= usage["nosql"]["maxBases"]:
pass # api.storage.create() would answer cloud_storage_limit
# 2. Before a large write — will it fit?
size = len(payload)
first = usage["object"]["storages"][0]
if size > first["quotaBytes"] - first["usedBytes"]:
pass # Free something, or api.cloud.addons.buy(service="object", gb=1)