[SOLVED] Error: Cannot create Parse.File with that data

I am trying to upload json file to IPFS and getting an error.

I have tested the following code:

const file = {aaa: 111, bbb:222};
const file1 = new Moralis.File("file.name", file);
file1.saveIPFS();
console.log("ipfsURL:", file1.ipfs());

Could anybody guide me to right direction?
Thanks.

it may be a way to provide the data in base64 format, there should be examples on this forum

1 Like

Ya, that’s it! Thanks!!

const file1 = new Moralis.File("file.name", {
        base64: btoa(JSON.stringify(file))
}
1 Like