From 54e2c4d6ddae656f0d78f82071e38c9b681e5aed Mon Sep 17 00:00:00 2001 From: rk <59029880+rrr523@users.noreply.github.com> Date: Fri, 8 Dec 2023 11:01:12 +0800 Subject: [PATCH] chore(example): Create folder on Nodejs (#416) --- examples/nodejs/cases/storage.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/examples/nodejs/cases/storage.js b/examples/nodejs/cases/storage.js index eaaa9ee2..02e76140 100644 --- a/examples/nodejs/cases/storage.js +++ b/examples/nodejs/cases/storage.js @@ -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); + } })();