Hi all,
I’m looking to store the NFT token image per token Id in the database so that pulling the images will be quicker, however, I’m running into the following issue when trying to “store” the file.
construct.js:25 Uncaught (in promise) Error: File upload by public is disabled.
at handleError (RESTController.js:435)
at async updateNFTImages (MyCats.js:28)
at async onClick (MyCats.js:36)
My cloud function looks approximately like this:
Moralis.Cloud.define("updateNFTImages", async (request) => {
const NFTImage = Moralis.Object.extend("NFTImage")
const nftImage = new NFTImage()
// do some stuff, I use web3 to get the nft contract
let i = 15
let tokenUri = await nftContract.methods.tokenURI(i).call()
let tokenUriResponse = await Moralis.Cloud.httpRequest({ url: tokenUri })
let imageData = await Moralis.Cloud.httpRequest({ url: tokenUriResponse.data.image })
// I actually don't think this next line is right... but whatever, just trying to see if I can even save a file
let bufferData = { base64: imageData.buffer.toString('base64') }
const imageFile = new Moralis.File(`${i}_cat.png`, bufferData)
nftImage.set("image", imageFile)
await nftImage.save()
}
Is there a better way for me to cache the image of an NFT so I don’t have to read it every time? The api call to get the image is really slow.