Skip to content

Instantly share code, notes, and snippets.

@fengmk2
Created June 13, 2012 14:05
Show Gist options
  • Save fengmk2/2924280 to your computer and use it in GitHub Desktop.
Save fengmk2/2924280 to your computer and use it in GitHub Desktop.
/**
* 淘宝指数 - 消失的密室
*/
var express = require('express');
var formDataParser = express.bodyParser.parse['multipart/form-data'];
// dont parse file upload
delete express.bodyParser.parse['multipart/form-data'];
var fs = require('fs');
var path = require('path');
..........
...........
...........
app.use(require('./lib/redirect')({ domain: 'taobao.com' }));
// handle file upload
app.use('/upload', function (req, res, next) {
if (req.body) {
return next();
}
req.body = {};
if ('GET' === req.method || 'HEAD' === req.method) {
return next();
}
var contentType = (req.headers['content-type'] || '').split(';')[0];
if (contentType !== 'multipart/form-data') {
return next();
}
formDataParser(req, {}, next);
});
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.session({
secret: config.session_secret,
cookie: { path: '/', httpOnly: true, maxAge: 3600000 * 12 },
store: new RedisStore(config.redisOptions)
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment