I've been exploring the capabilities of js-ipfs API and I'm curious to know if js-ipfs is limited to only uploading files/folders. Is there a way to upload other types of data, such as a JavaScript object like:
{
heading:"SomeHeading",
content:"somecontent"
}
or a string like
"{heading:\"SomeHeading\", content:\"somecontent\"}"
So far, my attempts have involved:
const ipfs = window.IpfsApi('localhost', 5001, {protocol: 'https'});
const buffer = ipfs.Buffer;
async function uploadToIpfs() {
let someObject = {
heading:"SomeHeading",
content:"someContent"
};
let objectString = JSON.stringify(someObject);
let bufferedString = await buffer.from(objectString);
await ipfs.add(bufferedString, (err, resp) => {
console.log(err);
console.log(resp);
});
}
but I encounter https://i.sstatic.net/smtdw.png
Any assistance in resolving this issue or a straightforward answer on whether it's feasible to directly upload a JS object or string would be highly appreciated!