Nest: Multer and Nest

Created on 15 May 2017  路  4Comments  路  Source: nestjs/nest

const upload = multer ({ dest: path})

I have: router.post('/uploadUserImage', upload.any(), api.uploadUserImage);

How i convert this in Nest ??

Most helpful comment

Hi @franciscoffavaro,
Just return upload.any() in resolve() method of Nest middleware.

@Middleware()
export class MulterMiddleware implements NestMiddleware {
    resolve(): (req, res, next) => void {
        const upload = multer({ dest: path });
        return upload.any();
    }
}

All 4 comments

You can hook into the express instance. I'm guessing you'd probably want to create a middleware wrapper for it.

Hi @franciscoffavaro,
Just return upload.any() in resolve() method of Nest middleware.

@Middleware()
export class MulterMiddleware implements NestMiddleware {
    resolve(): (req, res, next) => void {
        const upload = multer({ dest: path });
        return upload.any();
    }
}

@kamilmysliwiec I think a call to next() is missing

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VRspace4 picture VRspace4  路  3Comments

cdiaz picture cdiaz  路  3Comments

tronginc picture tronginc  路  3Comments

breitsmiley picture breitsmiley  路  3Comments

mishelashala picture mishelashala  路  3Comments