IPFS HTTP CLIENT
Dive into the specifics of connecting and using IPFS HTTP CLIENT with web3stash
Initialization
To use IPFS HTTP Client which actually allows you to connect to local or your own hosted ipfs providers you have to pass "IPFS-CLIENT" as the service name. No other name will work!
const ipfsClientService = Web3Stash("IPFS-CLIENT",{url:{}},{IPFS-Http-Client APIconfig options})
Configuration
To use IPFS Http Client in web3stash, you need one thing:
url- URL to connect to ipfs node
There are multiple ways of passing url-
// connect to ipfs daemon API server
const url = 'http://localhost:5001'
// or connect with multiaddr
const url = '/ip4/127.0.0.1/tcp/5001'
// or using options
const url = { host: 'localhost', port: '5001', protocol: 'http', headers:{} }
// or specifying a specific API path
const url = { host: '1.1.1.1', port: '80', apiPath: '/ipfs/api/v0' }
const ipfsClientService = Web3Stash("IPFS-CLIENT",{url:url})
Note: Use these names only while passing keys in objects i.e, {url:"",}
Optional Config Options
There are no configOptions for this service
Methods Available
The following methods are available for this service, More will be added soon
Uploading JSON data
ipfsClientService.uploadJson({name:"example", url:"abc.com"}, {ipfsClientOptions}).then().catch()
Uploading Image
ipfsClientService.uploadImage("./image.png", {ipfsClientOptions}).then().catch()
Uploading Video
ipfsClientService.uploadVideo("./video.mp4", {ipfsClientOptions}).then().catch()
Uploading File
ipfsClientService.uploadFile("./data.txt", {ipfsClientOptions}).then().catch()
Output
All the functions return id (cid) and metadata (data returned by the service on upload)
{id:"dewfnlpweurmwknrwiojhgcbxczz", metadata:{}}
Last updated