I can successfully upload images as NFTs on my marketplace, but when I try to upload a video, I get the following errors:
"XMLHttpRequest failed: “Unable to connect to the Parse API”
and
Here is the function in which things fail. As you can see in the logs, initially saving the file to IPFS works, but for some reason fails when trying to store the rest of the metadata.
async function createItem() {
setUploadLoading(true)
const re = /(?:\.([^.]+))?$/;
const fileExt = re.exec(selectedFile.name)
const fileName = 'file' + fileExt[0];
const nftFile = new Moralis.File(fileName, selectedFile);
try {
const savedFile = await nftFile.saveIPFS()
console.log('FILED SAVED')
console.log(savedFile)
const nftFilePath = savedFile.ipfs()
const nftFileHash = savedFile.hash()
const metadata = {
name,
description,
image: nftFilePath
};
const nftFileMetadataFile = new Moralis.File("metadata.json", {base64: btoa(JSON.stringify(metadata))});
const metadataSavedReceipt = await nftFileMetadataFile.saveIPFS();
console.log('METADATA FILE SAVED')
console.log(metadataSavedReceipt)
const nftFileMetadataFilePath = nftFileMetadataFile.ipfs()
const nftFileMetadataFileHash = nftFileMetadataFile.hash()
const nftId = await mintNFT(nftFileMetadataFilePath);
const Item = Moralis.Object.extend("Item")
const item = new Item();
item.set('name', name)
item.set('description', description)
item.set('nftFilePath', nftFilePath)
item.set('nftFileHash', nftFileHash)
item.set('metadataFilePath', nftFileMetadataFilePath)
item.set('metadataFileHash', nftFileMetadataFileHash)
item.set('nftId', nftId)
item.set('nftContractAddress', contractAddress)
console.log(contractAddress)
await item.save();
console.log(item)
}
catch(err) {
alert('Error: ' + err.message)
console.log(err)
}
}