Skip to content

Instantly share code, notes, and snippets.

@mderazon
Created August 19, 2015 10:50
Show Gist options
  • Save mderazon/0903aa7eb91fa1bd6380 to your computer and use it in GitHub Desktop.
Save mderazon/0903aa7eb91fa1bd6380 to your computer and use it in GitHub Desktop.
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