Welcome
User Guide
Developer guide
Reference Guide
Frequently Asked Questions
Pricing policy
Data retention policy
Draft: Default Space How to upgrade by payment?
How to re-subscribe to an expired DID Space
Connecting to the DID Space using the Gateway Address
Switch the DID Space bound to NFT Blender.
The automatic backup of Blocklet is stuck, how can it be quickly restored?
Fix CORS error when connecting DID Space
Change log
Draft: Purchase DID Space
DID Spaces v0.6.0: OAuth Integration in DID Spaces
DID Spaces v0.5.83: OAuth integrated DID Space
Prod Spaces data retention policy updated
DID Spaces v0.4.26 released: subscription fully adopts pay-as-you-go & supports paid upgrade Default Space
DID Spaces v0.3.75 released: Supports reading and writing component spaces
DID Spaces v1.0.48: 支持预览 post/bookmark/blog/doc
PutPreviewObjectCommand
PutPreviewObjectCommand
interface is designed for uploading preview objects within a specified space. Its primary function is to upload images, metadata, and other related resources to a designated path and then provide the upload result.
Parameter Types#
PutPreviewObjectCommandInput#
Parameter Name | Type | Essential | Default Value | Parameter Description |
---|---|---|---|---|
key | string | Y | None | The folder path must end with |
data | object | Y | None | View the template data (complex types not displayed in detail) |
metadata | object | N | {} | Store metadata with the option to include additional information |
hash | string | N | None | The hash value of the object, corresponding to the hash of the IPFS CID v1 |
resources | array | N | [] | A list of resources, with each resource associated with a key and data |
Return Type#
PutPreviewObjectCommandOutput#
Field Name | Type | Essential | Explanation |
---|---|---|---|
statusCode | number | Y | HTTP Status Codes |
statusMessage | string | N | Status Message |
Code Example#
Here is a sample code demonstrating how to use PutPreviewObjectCommand
to upload a preview object:
const { spaceEndpoint } = await spacesEndpointRepository.readUser(req.user.did);
const spaceClient = new SpaceClient({
endpoint: spaceEndpoint,
wallet,
});
const dataPath = join(process.env.BLOCKLET_APP_DIR, 'logo.png');
const data = fs.createReadStream(dataPath);
const output = await spaceClient.send(
new PutPreviewObjectCommand({
key: '/test-nft/',
data: {
template: 'nft',
did: 'zjduEsT5qiQr72tVtevGG3GwKjV6J4yHR9fy',
name: 'just test',
chainHost: 'https://beta.abtnetwork.io/api/',
image: 'nft.png',
},
resources: [
{
key: '/test-nft/nft.png',
data,
},
],
})
);
if (output.statusCode !== 200) {
logger.error(output);
return res.status(output.statusCode).send(output.statusMessage);
}
return res.send(output);
In this example, we start by obtaining the user's space endpoint, then use it along with the wallet to initialize the spaceClient
. Subsequently, we read the data for the preview object from local storage, configure the upload parameters using PutPreviewObjectCommand
, and finally, verify the output and return the upload result.