[solved] saveIPFS - code 130 error Not Allowed

I am creating a react app trying to mint an nft. Before I can mint, I need to upload an image file to IPFS however when I execute await imageFile.saveIPFS() I am getting a POST 400 error and Uncaught (in promise) Error: Not Allowed at handleError (RESTController.js:438:17). I know I am authenticated because I am logging isAuthenticated and that is returning true.


Here is a link to a codesandbox replicating the problem: https://codesandbox.io/s/nftminttest-r7brhb?file=/src/App.js

You are using a self hosted server or a Moralis server?

Moralis server, I am using react-moralis 1.4.0 and Moralis 1.11.0.

Can you look in network tab to see what is the error returned from the server?

The http response is {"code":130,"error":"Not Allowed"}.
The payload is:
{ base64: "/9j/4AAQSkZJRgABAQEASABIAAD/4gIcSUNDX1BST0ZJTEUAA... fileData: {ipfs: true, metadata: {}, tags: {}} _ApplicationId: "vrgP2asDtwbGyKQUitbcxEOHb34cEAfEicDRbezI" _ClientVersion: "js1.11.0" _ContentType: "image/jpeg" _InstallationId: "035470d4-4c68-4b5b-a129-f0fc29bb3733" _SessionToken: "r:48ad60f9e1ae86603bdbffeb27e568b2" }

Did it work before or this is the first time when you are trying to upload to ipfs?

Alternatively you can call a cloud function that makes the upload to ipfs. I can test later with vanilla js to see if it works for me.

This is the first time trying to upload to ipfs. I will try to call cloud function to upload if we cannot find a solution for this. I’m confused because ‘Not Allowed’ seems like an authentication issue but clearly I am authenticated.

I didn’t see that error before. You get an error when you are not authenticated, but that error has a different error message. Maybe something related or the parameters?

Is the output of Moralis.File correct? There is no documentation on what the correct response of that function should be.

I don’t know the exact format. I’m not at computer to check.

You can also use uploadFolder api function to upload a file to ipfs

Does the uploadFolder api function handle saveIPFS behind the scenes? What do the abi parameters mean? Is the path parameter the file.name? What goes into the content parameter?

You can find an example with the parameters directly on the documentation site: docs.moralis.io

I am looking at it, https://v1docs.moralis.io/moralis-dapp/web3-api/ipfs-storage-new#uploadfolder-new. It is still not clear. Is path the image source path or destination path? What exactly is the Content string?

Take a look at the new docs and try an example directly there with the default parameters. One is the content of the file in base64 and one is the path in the ipfs folder

based on this https://community.parseplatform.org/t/error-when-trying-to-save-new-file-in-aftersavefile/1686/3
it looks like somewhere “Unauthorised!” is raised

here it suggests to look in the database:

I figured it out! It was actually a cloud function I created to block any uploads for security purposes. So nothing to do with Moralis’ api functions.

1 Like