Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload with connect-multiparty #174

Open
ferreirajose opened this issue Feb 1, 2020 · 1 comment
Open

Upload with connect-multiparty #174

ferreirajose opened this issue Feb 1, 2020 · 1 comment

Comments

@ferreirajose
Copy link

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

@ferreirajose
Copy link
Author

ferreirajose commented Feb 1, 2020

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 };
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant