Skip to content

Commit

Permalink
chore(example): Create folder on Nodejs (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
rrr523 authored Dec 8, 2023
1 parent 493be54 commit 54e2c4d
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions examples/nodejs/cases/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,33 @@ console.log('objectName', objectName);
if (uploadRes.code === 0) {
console.log('upload object success', uploadRes);
}

// create folder example:
const createFolderTx = await client.object.createFolder(
{
bucketName: bucketName,
objectName: objectName + '/',
creator: ACCOUNT_ADDRESS,
},
{
type: 'ECDSA',
privateKey: ACCOUNT_PRIVATEKEY,
},
);
const simulateInfo = await createFolderTx.simulate({
denom: 'BNB',
});

const res = await createFolderTx.broadcast({
denom: 'BNB',
gasLimit: Number(simulateInfo?.gasLimit),
gasPrice: simulateInfo?.gasPrice || '5000000000',
payer: ACCOUNT_ADDRESS,
granter: '',
privateKey: ACCOUNT_PRIVATEKEY,
});

if (res.code === 0) {
console.log('create folder success', res);
}
})();

0 comments on commit 54e2c4d

Please sign in to comment.