Error: File upload by public is disabled

I am getting this error while uploading file to ipfs ,
I am already logged in to metamask. Also getting value in current user
let currentuser = Moralis.User.current();
But isAuthenticated is false I am not sure why. Please help me to solve this issue.

What version of the sdk are you using? That is vanilla js?

I am using reactjs version 18.0.0

Maybe you have to use useEffect if that is react

I am already using useEffect

With what dependencies?

useEffect we call on each page if we want something on page load right ?
I am not sure which dependency you are asking here for useEffect

@cryptokid are you there?

I am here. You add the dependencies in [] for useEffect

yes I did
RESTController.js:450 Uncaught (in promise) Error: File upload by public is disabled.
error is same while saving file in ipfs

How are you uploading to IPFS in your code?

But isAuthenticated is false I am not sure why

If using a react-moralis method for IPFS, you should login with authenticate from the useMoralis hook, not with Moralis.authenticate.

If you are using authenticate, then try it again until isAuthenticated returns true.

@alex Thanks for reply used same but its still returning false isAuthenticated.Sometime it return true and most of the time return false.
Using this for saving => const files =
new Moralis.File(imagename, data);

await files.saveIPFS();

How/when do you check that isAuthenticated?

@cryptokid
useEffect(() => {
init();
}, [isAuthenticated]);

Just before saveIpfs function I print it in console also on page load its false

And did you authenticate? I donโ€™t see anything about checking the value for isAuthenticated in that useEffect

Yes I authenticate @cryptokid and sometime it return true sometime it return false as I said earlier.This is inner page useEffect which i have mentioned above which i can access after authentication only.

You have to check that isAuthenticated value in that useEffect, how it is written now it will execute anytime the value changes for isAuthenticated

Itโ€™s better using hook all through, if youโ€™re doing it in a useEffect, you can always check for isInitialized before checking isAuthenticated. This is necessary in case of a refresh.
Also you got

const { user, isInitialized, isAuthenticated, authenticate } = useMoralis()

You can read about uploading a file using useMoralisFile hook here