Uncaught (in promise) Error: File upload by public is disabled

<!-- Moralis SDK code -->

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web3.min.js"></script>

<script src="https://unpkg.com/moralis/dist/moralis.js"></script>
<h1>IPFS DEMO</h1>

<button id="btn-login">Login</button><br><br>

<input type="text" name="metadataname" id="metadataname" placeholder="name"><br><br>

<textarea name="metadatadescription" id="metadatadescription" cols="30" rows="10"></textarea><br>

<input type="file" name="fileInput" id="fileInput"><br><br>

<button onclick=Go()>Go</button>

<script>

  // connect to Moralis server

  const serverUrl = "...............";

  const appId = "........";

   Moralis.start({ serverUrl, appId});

  //login

  login = async () => {

    Moralis.authenticate().then(function (user) {

        console.log('logged in');

    })

  }

 

  //upload image

  uploadimage = async() => {

    const data = fileInput.files[0];

    const file = new Moralis.File(data.name, data);

    await file.saveIPFS();

    console.log(file.ipfs(), file.hash());

    return file.ipfs();

  }

  //upload metadata object name description image

  uploadmetadata = async(imageURL)=>{

    const name =document.getElementById('metadataname').value;

    const description =document.getElementById('metadatadescription').value;

    const metadata = {

        "name" :name,

        "description" : description,

        "image" : imageURL

    }

    const file = new Moralis.File("file.json" ,{base64 : btoa(JSON.stringify(metadata))});

    await file.saveIPFS({useMasterKey:true});

    console.log(file.ipfs());

  }

  //go function

  Go = async()=> {

      const image =await uploadimage();

      await uploadmetadata(image);

  }

</script>

What is wrong in these code, I tried the {usemasterkey:true} this solution then also not working.
Can anyone please let me know what is issue.

You’ll have to authenticate first, e.g. with your login function.

Also read here as you shouldn’t use the master key in a frontend.

login = async () => {

Moralis.authenticate().then(function (user) {

    console.log('logged in');

})

}

Here it is authenticated. Then what actually is missing

and i removed the {usemasterkey:true} part from my code as it is not used in frontend.

If you can elaborate once it will be helpful.

Did you authenticate first by clicking the login button and signed with MetaMask and then go through the upload process?

I firstly click on my login button.
Then opened my metamask and login to Eth mainnet.
then i uploaded my file then also I am getting same error.

Isuue got solved thanks