Created
August 19, 2015 10:50
-
-
Save mderazon/0903aa7eb91fa1bd6380 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express') | |
var multer = require('multer') | |
var storage = multer.memoryStorage() | |
var upload = multer({ storage: storage }) | |
var app = express() | |
app.post('/upload', upload.single('users.csv'), function (req, res, next) { | |
if (!req.file) { | |
return res.status(400).send('No file uploaded') | |
} | |
// you can choose to restrict file types | |
if (req.file.mimetype !== 'text/csv') { | |
return res.status(400).send('File type must be csv') | |
} | |
// file is ready, access it in req.file | |
// ... | |
// ... | |
}) | |
app.listen(3000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment