06 云端配置 - MiEcosystem/miot-plugin-sdk GitHub Wiki

miot/service/storage

MIOT 云端提供的暂存服务

Export: public
Doc_name: 云端配置
Doc_index: 6
Doc_directory: service


miot/service/storage~ICloudStorage

Kind: inner interface of miot/service/storage


iCloudStorage.getUserConfigs(componentId, ...keys) ⇒ Promise

Deprecated

读取米家的用户配置信息 /user/get_user_config(获取/user/set_user_config写入的用户配置)

Kind: instance method of ICloudStorage
Returns: Promise - key,value结构数据

Param Type Description
componentId number 厂商APP_ID(Cloud ID),需要向小米申请, 0 和 1 预留
...keys number 保存的数据索引,从0开始

Example

getUserConfigs(componentId, k1,k2,k3).then(res => {...})

iCloudStorage.getThirdUserConfigs(model, ...keys)

Deprecated

读取三方数据,该接口读取厂商的用户配置信息 /user/get_third_user_config,对应的写的接口为:set_third_user_config。

Kind: instance method of ICloudStorage

Param Type Description
model string 设备Model
...keys number 根据key获取配置,如果不传keys 返回用户该厂商的所有配置

Example

getThirdUserConfigs(model, k1,k2,k3).then(res => {...})

iCloudStorage.setUserConfigs(componentId, data) ⇒ Promise

Deprecated

写数据 /user/set_user_config

Kind: instance method of ICloudStorage

Param Type Description
componentId string 厂商APP_ID(Cloud ID),需要向小米申请,0和1预留
data * key,value结构数据

iCloudStorage.setThirdUserConfigs(model, key, data)

Deprecated

写数据 /user/set_user_config, data的数据量不能超过2048字节

Kind: instance method of ICloudStorage

Param Type
model string
key number
data json

iCloudStorage.setThirdUserConfigsForOneKey(model, key, data) ⇒ [ 'Rromise' ].<any>

写数据 /user/set_user_config 创建或修改设置插件自由存储空间。如果数据超过服务器设置的阈值,自动分段存储到云端。 但是分段存储会占用额外的key,比如key=100时,分出的新段会存储在101,102,103...等后续相邻的key上, 因此如果插件方需要存储多个key-value,建议多个key之间相差较大

Kind: instance method of ICloudStorage
Returns: [ 'Rromise' ].<any> - Promise 成功时:true 失败时:{"code":xxx, "message":"xxx" }
Since: 10023

Param Type
model string
key number
data json

iCloudStorage.getThirdUserConfigsForOneKey(model, key) ⇒ [ 'Promise' ].<any>

与setThirdUserConfigsForOneKey配套使用,会把分段的数据自动合并后返回,使得分段行为对调用者透明

Kind: instance method of ICloudStorage
Returns: [ 'Promise' ].<any> - 成功时:{key:xxx, data:xxx} data 为set时的数据 失败时:{"code":xxx, "message":"xxx" }
Since: 10023

Param
model
key

iCloudStorage._convertParamsForThirdUserConfig(model, key, data) ⇒ *

需要考虑存储数据的大小,数据量太大需要分段存储

Kind: instance method of ICloudStorage
Returns: * - datas:[]

Param
model
key
data

⚠️ **GitHub.com Fallback** ⚠️