Created
July 15, 2020 04:50
-
-
Save viraj124/e28149dfcdfd7f006d3ff63016ff8a3c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; | |
const { SpaceClient } = require('@fleekhq/space-client'); | |
const client = new SpaceClient({ | |
url: `http://0.0.0.0:9998`, | |
}); | |
(async ()=>{ | |
const bucket = "buckettoshare" + Date.now(); | |
try { | |
console.log('creating bucket...'); | |
const res = await client.createBucket({ slug: bucket}); | |
const bucketObj = res.getBucket(); | |
console.log(bucketObj); | |
} catch (error) { | |
console.error(error); | |
} | |
try { | |
console.log('creating folder...'); | |
await client.createFolder({ bucket, path: "testFolderA" }); | |
console.log('folder created!'); | |
} catch (error) { | |
console.error(error); | |
} | |
try { | |
console.log('fetchig directory...'); | |
const res = await client.listDirectory({ bucket, path:"" }); | |
const entryList = res.getEntriesList(); | |
console.log(entryList); | |
} catch (error) { | |
console.error(error); | |
} | |
try { | |
console.log('sharing bucket...'); | |
const res = await client.shareBucket({ bucket }); | |
const threadInfo = res.getThreadinfo(); | |
console.log({ | |
bucket, | |
key: threadInfo.getKey(), | |
addressList: threadInfo.getAddressesList(), | |
addresses: threadInfo.getAddressesList().join(', '), | |
}); | |
} catch (error) { | |
console.error(error); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment