Error: Request failed with status code 413

Hi! I am trying to upload images to ipfs. I need to upload 5555 images, but my code only works with like 20 images. Otherwise I get a big nasty error andI think it is a problem on the Moralis side of things. Please help!!!

Here is my code:

let fs = require("fs");
let axios = require("axios");
let Moralis = require('moralis/node');
const serverUrl = "https://wafhxjairicm.usemoralis.com:2053/server";
const appId = "7YsTADQstpGlcRj3pXOMVV8crTBdklv8XehAxyrf";
const masterKey = removed;
let IPFSArray = [];
let promises = [];

const SaveData = async () => {

    await Moralis.start({ serverUrl, appId, masterKey });

    for (let i = 1; i< 1000; i++){

        /*Creating the image index*/
        let paddedHex = ("0000" + i.toString()).substr(-4);
        let paddedHexActual = ("0000000000000000000000000000000000000000000000000000000000000000" + i.toString(16)).substr(-64);
        /*Reading image and setting it*/
        
        promises.push(new Promise( (res, rej) => {

            fs.readFile(`./Badboys/${paddedHex}.jpg`, (err, data) => {
            
                IPFSArray.push({
                    
                        path:`images/${paddedHexActual}.jpg`,
                        content: data.toString("base64"),

                })
                res();
                
                
            })

        }))
        

}
Promise.all(promises).then( async () => {
    axios.post("https://deep-index.moralis.io/api/v2/ipfs/uploadFolder", 
    IPFSArray,
    {
        headers: {
            "X-API-KEY": 'peotZpDKBK8OVRViPDkHZgDbf4tHg2isPn0xaQdD1PoI5wxBBJeP3uOAHnoWpSUm',
            "Content-Type": "application/json",
            "accept": "application/json"
        },
        'maxContentLength': Infinity,
        'maxBodyLength': Infinity
    }
).then( (res) => {
    console.log(res.data);
})
.catch ( (error) => {
    console.log(error)
})

})

}

SaveData();

Here is the error:

Error: Request failed with status code 413
    at createError (C:\Users\tubvi\OneDrive\Stalinis kompiuteris\IPFS\node_modules\axios\lib\core\createError.js:16:15)
    at settle (C:\Users\tubvi\OneDrive\Stalinis kompiuteris\IPFS\node_modules\axios\lib\core\settle.js:17:12)
    at IncomingMessage.handleStreamEnd (C:\Users\tubvi\OneDrive\Stalinis kompiuteris\IPFS\node_modules\axios\lib\adapters\http.js:322:11)
    at IncomingMessage.emit (node:events:539:35)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  config: {
    transitional: {
      silentJSONParsing: true,
      forcedJSONParsing: true,
      clarifyTimeoutError: false
    },
    adapter: [Function: httpAdapter],
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 0,
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: Infinity,
    maxBodyLength: Infinity,
    validateStatus: [Function: validateStatus],
    headers: {
      Accept: 'application/json',
      'Content-Type': 'application/json',
      'X-API-KEY': 'peotZpDKBK8OVRViPDkHZgDbf4tHg2isPn0xaQdD1PoI5wxBBJeP3uOAHnoWpSUm',
      'User-Agent': 'axios/0.26.1',
      'Content-Length': 165612249
    },
    method: 'post',
    url: 'https://deep-index.moralis.io/api/v2/ipfs/uploadFolder',
    data: '[{"path":"images/0000000000000000000000000000000000000000000000000000000000000003.jpg","content":"hex code here'... 165602249 more characters
  },
  request: <ref *1> ClientRequest {
    _events: [Object: null prototype] {
      abort: [Function (anonymous)],
      aborted: [Function (anonymous)],
      connect: [Function (anonymous)],
      error: [Function (anonymous)],
      socket: [Function (anonymous)],
      timeout: [Function (anonymous)],
      prefinish: [Function: requestOnPrefinish]
    },
    _eventsCount: 7,
    _maxListeners: undefined,
    outputData: [],
    outputSize: 0,
    writable: true,
    destroyed: false,
    _last: true,
    chunkedEncoding: false,
    shouldKeepAlive: false,
    maxRequestsOnConnectionReached: false,
    _defaultKeepAlive: true,
    useChunkedEncodingByDefault: true,
    sendDate: false,
    _removedConnection: false,
    _removedContLen: false,
    _removedTE: false,
    _contentLength: null,
    _hasBody: true,
    _trailer: '',
    finished: true,
    _headerSent: true,
    _closed: false,
    socket: TLSSocket {
      _tlsOptions: [Object],
      _secureEstablished: true,
      _securePending: false,
      _newSessionPending: false,
      _controlReleased: true,
      secureConnecting: false,
      _SNICallback: null,
      servername: 'deep-index.moralis.io',
      alpnProtocol: false,
      authorized: true,
      authorizationError: null,
      encrypted: true,
      _events: [Object: null prototype],
      _eventsCount: 10,
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: 'deep-index.moralis.io',
      _readableState: [ReadableState],
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: undefined,
      _server: null,
      ssl: [TLSWrap],
      _requestCert: true,
      _rejectUnauthorized: true,
      parser: null,
      _httpMessage: [Circular *1],
      [Symbol(res)]: [TLSWrap],
      [Symbol(verified)]: true,
      [Symbol(pendingSession)]: null,
      [Symbol(async_id_symbol)]: 4043,
      [Symbol(kHandle)]: [TLSWrap],
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kCapture)]: false,
      [Symbol(kSetNoDelay)]: false,
      [Symbol(kSetKeepAlive)]: true,
      [Symbol(kSetKeepAliveInitialDelay)]: 60,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(connect-options)]: [Object],
      [Symbol(RequestTimeout)]: undefined
    },
    _header: 'POST /api/v2/ipfs/uploadFolder HTTP/1.1\r\n' +
      'Accept: application/json\r\n' +
      'Content-Type: application/json\r\n' +
      'X-API-KEY: peotZpDKBK8OVRViPDkHZgDbf4tHg2isPn0xaQdD1PoI5wxBBJeP3uOAHnoWpSUm\r\n' +       
      'User-Agent: axios/0.26.1\r\n' +
      'Content-Length: 165612249\r\n' +
      'Host: deep-index.moralis.io\r\n' +
      'Connection: close\r\n' +
      '\r\n',
    _keepAliveTimeout: 0,
    _onPendingData: [Function: nop],
    agent: Agent {
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      defaultPort: 443,
      protocol: 'https:',
      options: [Object: null prototype],
      requests: [Object: null prototype] {},
      sockets: [Object: null prototype],
      freeSockets: [Object: null prototype] {},
      keepAliveMsecs: 1000,
      keepAlive: false,
      maxSockets: Infinity,
      maxFreeSockets: 256,
      scheduling: 'lifo',
      maxTotalSockets: Infinity,
      totalSocketCount: 1,
      maxCachedSessions: 100,
      _sessionCache: [Object],
      [Symbol(kCapture)]: false
    },
    socketPath: undefined,
    method: 'POST',
    maxHeaderSize: undefined,
    insecureHTTPParser: undefined,
    path: '/api/v2/ipfs/uploadFolder',
    _ended: true,
    res: IncomingMessage {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 4,
      _maxListeners: undefined,
      socket: [TLSSocket],
      httpVersionMajor: 1,
      httpVersionMinor: 1,
      httpVersion: '1.1',
      complete: true,
      rawHeaders: [Array],
      rawTrailers: [],
      aborted: false,
      upgrade: false,
      url: '',
      method: null,
      statusCode: 413,
      statusMessage: 'Payload Too Large',
      client: [TLSSocket],
      _consuming: true,
      _dumped: false,
      req: [Circular *1],
      responseUrl: 'https://deep-index.moralis.io/api/v2/ipfs/uploadFolder',
      redirects: [],
      [Symbol(kCapture)]: false,
      [Symbol(kHeaders)]: [Object],
      [Symbol(kHeadersCount)]: 16,
      [Symbol(kTrailers)]: null,
      [Symbol(kTrailersCount)]: 0,
      [Symbol(RequestTimeout)]: undefined
    },
    aborted: false,
    timeoutCb: null,
    upgradeOrConnect: false,
    parser: null,
    maxHeadersCount: null,
    reusedSocket: false,
    host: 'deep-index.moralis.io',
    protocol: 'https:',
    _redirectable: Writable {
      _writableState: [WritableState],
      _events: [Object: null prototype],
      _eventsCount: 3,
      _maxListeners: undefined,
      _options: [Object],
      _ended: true,
      _ending: true,
      _redirectCount: 0,
      _redirects: [],
      _requestBodyLength: 165612249,
      _requestBodyBuffers: [],
      _onNativeResponse: [Function (anonymous)],
      _currentRequest: [Circular *1],
      _currentUrl: 'https://deep-index.moralis.io/api/v2/ipfs/uploadFolder',
      [Symbol(kCapture)]: false
    },
    [Symbol(kCapture)]: false,
    [Symbol(kNeedDrain)]: false,
    [Symbol(corked)]: 0,
    [Symbol(kOutHeaders)]: [Object: null prototype] {
      accept: [Array],
      'content-type': [Array],
      'x-api-key': [Array],
      'user-agent': [Array],
      'content-length': [Array],
      host: [Array]
    }
  },
  response: {
    status: 413,
    statusText: 'Payload Too Large',
    headers: {
      date: 'Sat, 09 Apr 2022 16:53:39 GMT',
      'content-type': 'text/html',
      'transfer-encoding': 'chunked',
      connection: 'close',
      'cf-cache-status': 'DYNAMIC',
      'expect-ct': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
      server: 'cloudflare',
      'cf-ray': '6f94c1959b7e0e26-MXP'
    },
    config: {
      transitional: [Object],
      adapter: [Function: httpAdapter],
      transformRequest: [Array],
      transformResponse: [Array],
      timeout: 0,
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: Infinity,
      maxBodyLength: Infinity,
      validateStatus: [Function: validateStatus],
      headers: [Object],
      method: 'post',
      url: 'https://deep-index.moralis.io/api/v2/ipfs/uploadFolder',
      data: '[{"path":"images/0000000000000000000000000000000000000000000000000000000000000003.jpg","content":"/9j/4AAQSkZJRgABAQAAAQABAAD/4QAMTmVvR2VvAAAAWv/+AENCbGVuZGVyOkZpbGU6QzpcVXNlcnNcdHVidmlcRHJvcGJveFxCbGVuZGVyIEZpbGVzXGRvbmVkb25lLmJsZW5kAP/+ACNCbGVuZGVyOkRhdGU6MjAyMi8wNC8wMyAwMToyNzowMwD//gAbQmxlbmRlcjpUaW1lOjAwOjAwOjAxOjAxAP/+ABVCbGVuZGVyOkZyYW1lOjAwMDMA//4AGEJsZW5kZXI6Q2FtZXJhOkNhbWVyYQD//gAWQmxlbmRlcjpTY2VuZTpTY2VuZQD//gAeQmxlbmRlcjpSZW5kZXJUaW1lOjAwOjEyLjA3AP/bAEMAAwICAwICAwMDAwQDAwQFCAUFBAQFCgcHBggMCgwMCwoLCw0OEhANDhEOCwsQFhARExQV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FL2opMUAFLSUUAFBoopgFFFGaACiiigAooooAKKKSgBaKSigBaSiigAooooAKKWjFACUtFFMAooooAKKKKYBRRRQAUtJRQAUUUUwCikooAXNFJRQAUUUdKACiiigAooozigAopKO9AC0UlFAC/hRSZ4ooAKKKKdgCjORRRRYAopKKYC0UlFABRRRQAUUUUABooooAKKKKBBRRRQAUUUUBcKKKOlArhRRSUwFoopKAClpO1FFgCiijrTsAUZ5o4opgFAozSdKBBS0lFAC0lFFABRRRQAUUUUAFFFJQAUUUUAFFFJQAtFJRQAtIaKO1AE9FFFeUahRRRQAUUUUAFFFFABRRRQAUUdqKACj2oooAKKSlp2AKKKKYBRRRQAUUEUUAGKXFAo7UAFFFFABiilooAKKKKACikooAWikopgLRRSUWAWg0UU7AFGaSloAKM0UlMBaKSloAKKTPFFAC0UnelFABRSUtABRQaKACikzS0AFFJRQAtFFJTsAtFFFABRRSUwFooo60AJSiiimAUUUUAFFFJQAtFJS0AFBopKAFpKXvRQAUhoooAWjFJRQAtFJRQAtJ1o5op2AKU0lFMApaSigApaSigQUdKKKAuFGaO9GaAuFFFFAgooooAM8UUUUAFFFFABmiikpgLR3pKWgApKKWmAUlFFABRRRQAUdKKBTAKKKO9AAKKSigBaKKM0AFFJS0AFFJS0AJRRRQAtFFFACUUtFMAoox+NFFgCiiigAxRRRTsAUUUUAFFJS0wCikooAWikzRQAUZoooAKKKKACiiigAo70GkoAWikooAWkoo70AFFFJQAtGaKSnYBaKSiiwBS0hopgFFFFABRRRQAUUUUAGaKKKBBRRRQAUUUUBcDRRRQIOtFFFAgooopjCiikoEFFHWimAUUUUAFFHaimAUUUUAFJS5pKAFopKKACiig0AFFFFABRRSCgAooozQAZooooAOtFJmjNAC0UlHagAopaSmAUUUlOwC9aSlpKAJ6KKK8g1CiijvQAUUUd6AFopKKACiiinYAooopgFLRSUAFLRRQAUYoooAWikooAXFFJS0AFFFAoEFFJS0ABooopgFFHeigAozzRSd6YCiiikzTAUc0UUUAFGaSigBaKM0fzoAKKTvS5oAKKKKACiiigBaSkooAWijpRQMO9FFFMQUUUYpjCjpRS0AIaKXpRQISloopgFFFFABRSUUDDNHWiigA7UUUUCClpKKACijpRQAUZoooAKM0dKKYB1oooNABRSUtMYUZoooEFFFFAXCiiigLhRSUtAgo60UUAFFFFAB3pKKKAFopM0UwCiiigBc0lFFABRRRTAKKKKACiiimAUUUUAFGaKKACijNJQAtFHeigApKKKACiiigAoopaAEopaKAEpaKOlMAoooosAUUUUwCiikoAWikooAXrSUZopgLSUUUAFFFGaACijvRQAUUnWigBaKTNFAC0nSjpRQAZozRRmgAopKWgAziikopgFLSUUwCiiigAooooAKKKKACiiigApKWigQUUUUAFFFFArhRS0lABRRRQAUUUUxBRR0ooAKKKKLAFFFFMANFJRTAWkoNAoADQaKSgBaKSjvQAUUUZoAKKKKADrRRRQAUUlFAC0UUnagAoozRQAUUUUAFFFJmmAUUUUAFFFFMAoNFJQAtFJRTAKM0UUAFFFJQBYoo60d68ixqFFFFABR3o60UwCiiigAooooAWikooAWikooAWikooELRSUtABRSUtMQUUlLQAUUlLQAUUUUxhRRRQAUUUUxBRRSZoGKKKM0UCCiiigYUUUUAFFFFABRRRQAUUUUAFFFFMAooxS4pgFH40UdKACilpKYBRS0lABS0UlAC0lFFAC0UlFAC0lFFABRRRQAUUUUAFFFFABRSCinYBcUUUUWAKKKSmAtFFJQAtFFJQK4tFJRQAuaKSigBTRSUUALSZoooAXvSUUUwDrRRRQAUUUUAFFFFOwBRRRQAUUUUwCijNFABRRSUALR3opKACiiigBaSiigBaSiigAooooAKKWigBKMUvSimAUdqKM0WAKKM0UwCikooAKWkooAWk7UZooAKKKKYBRRSUALRSe9FAC5opKKAFzR1pM0ZoAKKKKACjNA4ooABRSUtFgEpaSinYBaKSigAooopgFFFFABRRRQAUUUUCEpaOtFABiiiigAoopcUAJRRS0CEooooEFFLSUAFFFGaYBRRmigAzRRRTAKKKKLAFFJR2pgLSZo60UAFFFFABRRRQAGjNJRmgAzRRRQAUUUUAFJS0lAC0lLSUALSUUUAFFFFOwBRRRQAUdaKTNMAooooAKKKSmAtAopKAFzSUUUAFFFFABmiiigApKKKAFpKKKALFJRRXkmotJS9aTvQAtFFFABmijNFArhQKSloC4UUUUCCiiimAUUUmKAFooo60wDtRRRQAUUUUwCiiigAzRRmigAooooAM0UUUAFFFFABRRRQAUUUUAFBopetMBKWiigBKWjFFMAopaKACiiimAUdKKKACjNFFAwoopKAFo70Z/OigQUUUUDCiiigAoooPSgAooopgGaKSigAooopgFLSUUCCiiigAooooAKKKKACiiigA6UUUUAFFFFABRRRQAUUUUwCigUlAC0UUnemAtFJS0wCikooAWikooAWikooAKKKKACiiigA6UUUUAFFFFAAaKO9FABRS0nagBaKSlpgGKKKSiwC0lFFMBaKSigAooopgFFHSigAzR0opKAFoNJRQAtFJ3ooAM4ooooAKKSlzQAUUlFAC0UlFAC0UlFMAooooAKM0UUwCiiigAopKWgAooooEFJS0UAHeiiigAoopaBXEoopaAuJS0UUCCjiikoAWikozTAKKKKACijtRTAKKM0d6ACikopgFLSUUAFFFJQAtFGaTtQAtGaM0lAC9qM0lFACmkoooAKO1FFABRRRmgA6UlLSdKAFzRmkopgFFFFABRR2opgFFFJ1oAOtGaOKKAFpKM0dKACikpaYBSUUUAFFFFABRRRQAUUUlABRRRQAUUUUAFFFFABRSUdqYFiikpa8gsKKKKACiijNMAooooAKXNJRQAZopM0tMAooopgFFFFABmijpRQAUUUUAFFFGaAClpKM0AFGaKKACijtRQAtJS0UAJS0UUwCjrS0lABS0UUwCiijpQAtFJRTAWikooAXNJRRQAtJRR0oAKKKKACiiigBaKQ0UAAoozR/KgAooop2AKKKKYBRRRQAUUUUAFFFFABRRRQAUUUUAFFHWigAoopKAFoopKAFopKKYC0lFFAC9aSiinYBaSiiiwC0nWjvRTAKWkooAKKKKACiiigAooooAKKKM0AFFFFABRRiigAooooAMUZoooAKKKKdgCiiiiwBRRRTAOlFJS0AFFJRTAWk6UvSkoAWikzRQAvSikooABR2oooAM0dKKKADrRRRQAlLSUUALQaSigAooopgFFFJQAtFJS0wCikpaACjNFFAgooooAKKKKACiiigVwxxRS4zSUALSUdqWgQUlLSUALRSUUwCiijNABRmjNFFgCiikzTsAtFIKKAFopKKYBmiiigAzRRmkoAWikpaADNFJRQAZo7UUUAFFFFABRRRQAUUUCgAooooAKKKSmAtFJRTsAUUUUAFFFFABSUUUALSUUUwCijNFAB9aKKSgA7UUUUAFFFFABRRSUALRSUZoAM0UUUAHWijNFABRSUvamAUUUlABRRRTAKKKKALFJRRXkFhRRR3pgFFFFAC0ZpKKYBRRRQAtJRRQAUtJRQAUtJRQAUtJRQAtFJigUALRRRQAUUYzS0wExRS4oosAYooxRimAUUUuKAEpaKKYAKKSloAKKKKACjNFFABRRRQAUUUUAFFFFABRRRQAUUlLTAKKOlFABRmiimAUUlLQAUUUUAFFFFABRRRQAUUUUAJS0lLQAUUUUAJRRRTAKKKKACijpR3osAUUUUwA0ZoooAOtFAoNMAooooAKM0UUAFFJRQAtFFJQAtHWkooAWko6UtABRSUvWgBO9LSUtABRSZopgLRSUU7ALSUUUAFLmkooAKWkozTAKXNJRQAUUUdKACiijpQAUUdRRzQFgNFFFACUuaSigAooooAKKKKACiiigAooopgFFJRTAWkopaAEopaKBBSUuKMUAFFFFArhRRRQFwopaKAEopaSgQtGKTrRQAtApKKYBRRRQAUUUUAFFFFMAopKKAClpKKYBRRRQAUUUlAC0UlFAC0nWlpKACiigjFABRRRQAUUtJQAUUUUALSUdKKACiiimAUUUlMBaKSigBaSiigAoo6UUAFFFApgFFJRQAUUUd6ACijrRmgAooooATrRRRQAUUUUAFFJRQAUtJRQAUUUUwCiijNFgCkpaKYBSUUZoAKKKKACiiigApM0UUAFFFFAixRRRXlGgUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAdqKKKACilxRTAKKKXFMBKWiigAooooAKKM8UUwCiiigAooooAKKKKACg0ZozQAUtJmigA6UUUUAFFFAoAKKKKYBRRRTAWkoooAKKKKAFzRSUUAFLSUUAF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RRRQAd6KKDQAUUlFAC0UlLQAUUUUCCjrR1ooGFFJS0wCikpaYCUUUUAFFFFABRRRTAKKKKACikxS0AAooooAKKO1FAgopKOKBi0lLSY4oAWkoooAWikre8PeHG1JhNOCtsOg7v/APWpNpK7OihQqYmoqdNakGieH5tWfccx24PL+vsK7qysIbGFYoUCKPTvU8NukMaoihUUYAFSYrllJyPv8FgaeDjprLqxoFLilNIag9IaaSnUhoAaRSEU4mm0ANPWjFKaSgBuKQinUmaAGkUxuKkNMc8UAVp2wpqWFPLt1Hc8moZfnkVfU1bl449KAKzioWqV6ibigBhphFPNMNADDTDUh6000AQkUw1MaYwoAhYVGy1ORUZFAEDLxULJVllqNhQBUdKgkTg1dcVA60gKEkdVJY605EqrLHSAypY+tUpYua15Y6pyx9aAMt4utQvF2q9ImKgZaA'... 165602249 more characters
    },
    request: <ref *1> ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 7,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: false,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: false,
      maxRequestsOnConnectionReached: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: true,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      _contentLength: null,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      _closed: false,
      socket: [TLSSocket],
      _header: 'POST /api/v2/ipfs/uploadFolder HTTP/1.1\r\n' +
        'Accept: application/json\r\n' +
        'Content-Type: application/json\r\n' +
        'X-API-KEY: peotZpDKBK8OVRViPDkHZgDbf4tHg2isPn0xaQdD1PoI5wxBBJeP3uOAHnoWpSUm\r\n' +     
        'User-Agent: axios/0.26.1\r\n' +
        'Content-Length: 165612249\r\n' +
        'Host: deep-index.moralis.io\r\n' +
        'Connection: close\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: nop],
      agent: [Agent],
      socketPath: undefined,
      method: 'POST',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      path: '/api/v2/ipfs/uploadFolder',
      _ended: true,
      res: [IncomingMessage],
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: false,
      host: 'deep-index.moralis.io',
      protocol: 'https:',
      _redirectable: [Writable],
      [Symbol(kCapture)]: false,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype]
    },
    data: '<html>\r\n' +
      '<head><title>413 Request Entity Too Large</title></head>\r\n' +
      '<body>\r\n' +
      '<center><h1>413 Request Entity Too Large</h1></center>\r\n' +
      '<hr><center>nginx</center>\r\n' +
      '</body>\r\n' +
      '</html>\r\n'
  },
  isAxiosError: true,
  toJSON: [Function: toJSON]
}

Any help is apprechiated. Thank you!

1 Like

You could upload every image separately if that works for you. If not, you could try to use pinata.

1 Like

Hi @vilius, have you found a solution for your problem?
I am facing the same problem.

#########################################
Welcome to Rekt City - Meet the Survivors
#########################################

Error: Request failed with status code 413
    at createError (C:\DriveD\Projects\moralis-mutants-nft-engine-main\node_modules\axios\lib\core\createError.js:16:15)
    at settle (C:\DriveD\Projects\moralis-mutants-nft-engine-main\node_modules\axios\lib\core\settle.js:17:12)
    at IncomingMessage.handleStreamEnd (C:\DriveD\Projects\moralis-mutants-nft-engine-main\node_modules\axios\lib\adapters\http.js:293:11)
    at IncomingMessage.emit (node:events:538:35)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

This is my code above.
It mints 100 images to IPFS but when I tried to mint 200 images, I am getting this status code 413.

uploading the images one by one and not all in one folder could be a solution, but it may require some code changes

Here is the solution as far as i can understandโ€ฆ

exa:

let fs = require("fs");
let axios = require("axios");
let FormData = require('form-data');
let Moralis = require('moralis/node');
const serverUrl = "https://wafhxjairicm.usemoralis.com:2053/server";
const appId = "7YsTADQstpGlcRj3pXOMVV8crTBdklv8XehAxyrf";
const masterKey = "<your-master-key>";
let IPFSArray = [];
let promises = [];

const SaveData = async () => {

  await Moralis.start({ serverUrl, appId, masterKey });

  for (let i = 1; i < 1000; i++) {
    let paddedHex = ("0000" + i.toString()).substr(-4);
    let paddedHexActual = ("0000000000000000000000000000000000000000000000000000000000000000" + i.toString(16)).substr(-64);

    promises.push(new Promise((resolve, reject) => {
      fs.readFile(`./Badboys/${paddedHex}.jpg`, (err, data) => {
        if (err) {
          reject(err);
        } else {
          IPFSArray.push({
            path: `images/${paddedHexActual}.jpg`,
            content: data
          });
          resolve();
        }
      });
    }));
  }

  Promise.all(promises).then(async () => {
    const formData = new FormData();
    formData.append('files', JSON.stringify(IPFSArray));

    axios.post("https://deep-index.moralis.io/api/v2/ipfs/uploadFolder",
      formData,
      {
        headers: {
          "X-API-KEY": 'peotZpDKBK8OVRViPDkHZgDbf4tHg2isPn0xaQdD1PoI5wxBBJeP3uOAHnoWpSUm',
          ...formData.getHeaders()
        },
        maxContentLength: Infinity,
        maxBodyLength: Infinity
      }
    ).then((res) => {
      console.log(res.data);
    }).catch((error) => {
      console.log(error);
    });
  }).catch((error) => {
    console.log(error);
  });
};

SaveData();

This code modifies the file upload process to use FormData to handle the file uploads correctly. It appends the files and their metadata to the FormData object and sends it as the request body.
I hope this helps you.