Error: Cannot set property 'hash' of undefined

Hello, I am trying to save/upload a png to IPFS using saveIPFS method, but now I am getting the error “Error: Cannot set property ‘hash’ of undefined”

This is how i am calling the methods. The error seems to throw inside the saveIPFS method. Any idea what it could be? I followed the docs/tutorial pretty much exactly. (buffer is the base64 png string)
Maybe Im not supposed to use 'useMasterKey", but if I don’t put that in I get the “Error: File upload by public is disabled.” error.

const file = new Moralis.File('filename.png',{base64 : buffer});   
await nftFile.saveIPFS({ useMasterKey: true });       
const nftFilePath = nftFile.ipfs();
const nftFileHash = nftFile.hash();

Hi kedpack,

  • Have you upgraded your server to the latest version? Always try pressing the “Upgrade/Restart” button.
  • What is the size of the file being uploaded? The max file size is supposed to be 64MB but if you’re having problems with smaller file sizes then some of our settings may have gotten messed up.

I am getting the same error saving a file >2MB

Hello @_Ty useMasterKey is bypassing the error but I don’t believe you are actually authenticated. Are you providing the Master key in the Moralis.initialize call? This is not reccomened and authenticating is the preferred method.

Hey @rph, I am using an authenticated user (checked with user.attributes.authData.moralisEth.data logged to the console to be sure) and I am not using the Master key for the call. The only time I am using the master key is in cloud functions saving/finding data to/in the User table. Any file I save to ipfs using .saveIPFS() below 2mb goes through no problem, but when I try something larger I am getting the error mentioned above. Could there be an error in my code I am not seeing that would cause this? I haven’t dealt with this error message before

FYI there is a limit to Moralis.File sizes of around 3MB when saving to the database.

When saving to IPFS this limit should be closer to the 64MB limit mentioned in the docs. We’re working on fixing this issue.

I have the latest version of the server. Btw, I am doing in this Node,js (not UI), maybe I have to do something different? Actually now that i think about it that may be the issue. I am authenticated on frontend but not on backend… let me test it out

UPDATE

Ok so I confirmed it is same issue as @_Ty. When I upload a small image size (less than 2mb) it works. 2mb is really small cap for uploading an image on ipfs… is this a bug? (How does moralis database effect ipfs?)

@kedpak update your server to 0.0.223 they fixed it :+1:

3 Likes