Content to save on the IPFS network.
We currently support:
JSON (just pass the JSON or the stringified string)
File sent as a base64 encoded string
Please note that when uploading your file:
You must optimize your content to be less than 1 MB in size (there is a hard limit of 5MB when uploading files to IPFS using our API).
We currently support JSON, images, and PDF files.
If your use case requires higher file sizes or other file types, please contact us.
Upload to IPFS Examples
constfs=require('fs');constaxios=require('axios');/* get the file you want to upload to IPFS */constfileData=fs.readFileSync('./files/image.png');/* encode file content to base64 */constencodedData=fileData.toString('base64');/* build request to use BWS IPFS solution */constrequest= {"solution":"BWS.IPFS.Upload","operation":"new","parameters": { description:"My first IPFS file using BWS API!", parameters: { content: encodedData } }};/* call BWS API using Axios */let config = { method:'post', maxBodyLength:Infinity, url:'https://api.bws.ninja/v1/call', headers: { 'X-Api-Key':'XqaLg...... A5k2V729v',/* use your API key here! */'Content-Type':'application/json' }, data :JSON.stringify(request)};axios.request(config).then((response) => {console.log(JSON.stringify(response.data)); }).catch((error) => {console.log(error); });
When the API call is successfully executed, it returns the IPFS Content Identifier (CID) along with the corresponding IPFS URI and URL. These details facilitate easy access and reference to the uploaded content on the IPFS network.