javascript npm install web3.storage golang go get github.com/web3-storage/go-w3s-client
create a client instance
1 2 3 4 5 6 7 8
//get the access token function getAccessToken(){ return process.env.TOKEN } //creata an instance function makeStorageClient(){ return new Web3storage({token:getAccessToken()}) }
preparing files for uploading
1 2 3 4
function getFiles(){ const fileInput = document.querySelector('input[type="file"]') return fileInput.files }
upload files to web3.storage
1 2 3 4 5 6
//async upload process async function storageFiles(files){ const client = makeStorageClient() const cid = await client.put(files) return cid }
directory wrapping
after uploading you’ll get a cid of the directory and then the entire link gonna be ipfs:/// to make a gateway link :