baugarten/node-restful

Upload with connect-multiparty

Opened this issue · 1 comments

how can i use node-restful with connect-multiparty ?

routes.js

`
const express = require('express');
const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('../../swagger.json');

module.exports = (server) => {

const routerAPI = express.Router();
server.use('/api', routerAPI);
server.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));

const User = require('../api/user/userService');
User.register(routerAPI, '/users');

const AnexoService = require('../api/anexo/anexoService');
routerAPI.post('/upload', AnexoService.upload);

}
`

anexoService.js

`
const path = require('path');
const multiparty = require('connect-multiparty');

const pathDir = path.join(__dirname, '../upload');

const multipartyMiddleware = multiparty({ uploadDir: pathDir})

const upload = (multipartyMiddleware, function(req, res, next) {
console.log(req); // undefined

// var file = req.files.file; // undefined
// console.log(file.name);
// console.log(file.type);

});

module.exports = { upload };
`