Hi, I am building an react app with Moralis. So far so good except 1 thing. I want the user to be able to upload a image to ipfs however, when I call the function
Web3Api.storage.uploadFolder();
It works correctly but the link I get for image redirect me to a small white square.
I understand that the issue comes from the content I choose to put for my image following a pattern lke this
const options = {
abi: [
{
path: "moralis/logo.jpg",
content: "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3",
},
],
};
To get the content I do the following
const readFile = async (elem) => {
const data = elem.target.files[0]
const file = new Moralis.File(data.name, data);
}
file gives me a ParseFile object.
const options = {
abi: [
{
path: "moralis/logo.jpg",
content: file,
},
],
};
But it seems like moralis ipfs cannot interpret it and return me a blank square when I visit the link of my freshly uploaded image.
I am really not sure what to do here? I suppose I need to transform my image into some base64 array? Is there a way to do this with moralis?