Home > database >  npm connect-multiparty 'TypeError: Cannot read properties of undefined (reading 'path'
npm connect-multiparty 'TypeError: Cannot read properties of undefined (reading 'path'

Time:10-17

The connect-multiparty package is giving me some trouble; When I'm running my website locally, it works perfectly fine, saves the uploaded multiform data as intended, but when running on AWS Elastic Beanstalk, I run into the error TypeError: Cannot read properties of undefined (reading 'path')

The first bit of my backend code is here:

    const multipart = require('connect-multiparty')

    consts.mainRouter.post(`/*`, mpmw, (req, res, next) => {

        index.log(`mainRouter got posted in uploads: ${req.url}`)
        next()

    })

    consts.mainRouter.post(`${prefix}`, mpmw, async (req, res) => {
        index.log(`upload request received`)
        const account_data = await consts.accountExists(req.signedCookies)

        console.log(req.body)
        console.log(req.files)

        let { audio, thumbnail } = req.files
        let { name, collab } = req.body

        let imageblobin = fs.readFileSync(`${thumbnail.path}`)
        let imageblob = undefined
        let imagebloblarge = undefined
        let newtime = new Date().getTime()

On the "fs.readFileSync()" line, the error occurs; What could go wrong on AWS Elastic Beanstalk here that would work fine on my local machine?

Note: I am 100% sure that the request was correctly made, it previously worked, and only the backend was changed since

CodePudding user response:

Turns out there was something wrong with the EB environment I was using (sadly don't know what); I swapped the backend to a different environment which isn't blocking my multipart/form-data requests and therefore doesn't bring this error.

  • Related