GetObjectCommand
GetObjectCommand 可以帮助开发者获取 DID Space 上的对象数据。
参数类型#
参数名 | 类型 | 必要 | 默认值 | 说明 |
---|---|---|---|---|
key | string | Y | 无 | 可以是一个文件名或者文件夹 |
返回类型#
参数名 | 类型 | 必要 | 说明 |
---|---|---|---|
statusCode | number | Y | 返回状态码 |
statusMessage | string | N | 一般来说,发生错误的时候才会有值 |
stack | string | N | 堆栈信息 |
data | Readable | Y | 获取到的对象数据 |
headers | AxiosResponseHeaders | Y | 响应头信息 |
代码示例#
- 读取对象数据
const { SpaceClient, GetObjectCommand } = require('@blocklet/did-space-js');
const getWallet = require('@blocklet/sdk/lib/wallet');
const spaceClient = new SpaceClient({
endpoint,
wallet: getWallet(),
});
const { data } = await spaceClient.send(
new GetObjectCommand({
key: 'hello world!',
})
);
console.log(await streamToString(data));