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

marshall007 picture marshall007  路  3Comments

VRspace4 picture VRspace4  路  3Comments

hackboy picture hackboy  路  3Comments

rafal-rudnicki picture rafal-rudnicki  路  3Comments

cojack picture cojack  路  3Comments