Uploading files to IPFS

I’m working on a music NFT dApp and I am having issues when I try to mint files over a few kb. I am able to upload small images and small audio files – https://testnets.opensea.io/collection/name-82wreq3bmg

Here are the errors I am getting. Any idea what I’m doing wrong here? 1error

Do you get any errors in your self-hosted server’s terminal?

Yes, I’m getting PayloadTooLargeError: request entity too large

Another user had this issue, try the solution at the bottom.

It works. Thank you so much. Been stuck on this for so long lol.

Larger files work now, but i’m still getting this error on some of them

error: [C0006] Request failed: Request body larger than maxBodyLength limit {“code”:141,“stack”:“Error: [C0006] Request failed: Request body larger than maxBodyLength limit\n (1)\parse-server-migration\build\cloud\generated\evmApi.js:410:15\n at runMicrotasks ()\n at processTicksAndRejections (node:internal/process/task_queues:96:5)”}

What is the size of these uploads that fail? Is it consistent with each upload e.g. if you retry the same file?

You may need to use axios to make a direct request instead of the SDK (if that’s what you’re using) - see this similar topic.

1 Like

The size of the uploads is around 15mb

Did that solution work?

No, still trying to figure out the issue. files smaller than ~ 15mb seem to work fine.

Here’s the code for axios call. I’ve read that i could need to add – " ‘maxContentLength’: Infinity, ‘maxBodyLength’: Infinity " —

import axios from “axios”

export const toneGardenMarket = ‘0x45846bD83C49ee0148354a491703cad98Da17Dfc’

export const allowedChains = { ‘5’: ‘goerli’, ‘80001’: ‘mumbai’, ‘97’: ‘binance’, ‘1’: ‘eth’ }

export const contractsAddresses = { ‘0x5’: ‘’, ‘0x13881’: ‘0x45846bD83C49ee0148354a491703cad98Da17Dfc’, ‘0x61’: ‘’, ‘0x1’: ‘eth’ }

export const MAX_FILE_UPLOAD_SIZE = 8589934592

export const returnMetaData = (token_uri) => {

const options = {

    " Content-Type": "application/json"

}

axios.get(`${token_uri}?format=json`, options).then((res) => { return res.data }).catch((err) => { })

}

export const returnImage = (image, image_url) => {

if (image != undefined) {

    if (image.toString().startsWith('ipfs://')) {

        return image.replace('ipfs://', 'https://ipfs.moralis.io:2053/ipfs/')

    } else {

        return image

    }

} else if (image_url != undefined) {

    if (image_url.toString().startsWith('ipfs://')) {

        return image_url.replace('ipfs://', 'https://ipfs.io/ipfs/')

    } else {

        return image_url

    }

}

}

Can you please read this on posting code.

It is mentioned in the previous link. I’m not seeing the maxBodyLength option in use with your code.

1 Like

Ok here we go - and yes i’ll be trying to add maxContentLength and maxBodyLength today

import axios from "axios"

export const toneGardenMarket = '0x45846bD83C49ee0148354a491703cad98Da17Dfc'

export const allowedChains = { '5': 'goerli', '80001': 'mumbai', '97': 'binance', '1': 'eth' }

export const contractsAddresses = { '0x5': '', '0x13881': '0x45846bD83C49ee0148354a491703cad98Da17Dfc', '0x61': '', '0x1': 'eth' }

export const MAX_FILE_UPLOAD_SIZE = 8589934592

export const returnMetaData = (token_uri) => {

    const options = {

        " Content-Type": "application/json"

    }

    axios.get(`${token_uri}?format=json`, options).then((res) => { return res.data }).catch((err) => { })

}

export const returnImage = (image, image_url) => {

    if (image != undefined) {

        if (image.toString().startsWith('ipfs://')) {

            return image.replace('ipfs://', 'https://ipfs.moralis.io:2053/ipfs/')

        } else {

            return image

        }

    } else if (image_url != undefined) {

        if (image_url.toString().startsWith('ipfs://')) {

            return image_url.replace('ipfs://', 'https://ipfs.io/ipfs/')

        } else {

            return image_url

        }

    }

}

It looks like the code tries to get data from ipfs and not to upload it?

Yes you’re right, I’m not sure where the " ‘maxContentLength’: Infinity, ‘maxBodyLength’: Infinity " should go because that is the only place We used axios

Maybe this example helps