Authored by weiqingting

图片上传优化

... ... @@ -17,25 +17,30 @@ var errBackMsg = {
//var domain = 'http://172.16.6.227:8088/platform'; //马力
// var domain = 'http://172.16.6.162:8088/platform';
//var domain = 'http://172.16.6.240:8088/platform';
exports.uploadFile = function (req, res) {
function getHeader(req,res){
var headers = {};
if (req.session && req.session.user) {
var ipObject = ipaddr.process(req.ip).octets;
var ipObject = ipaddr.process(req.ip).octets
var ip = ipObject ? ipObject.join('.') : req.ip;
headers = {
'x-user-id': req.session.user.auth.pid,
'x-user-name': req.session.user.auth.account,
'x-site-type': 1,
'x-client-ip': ip
};
}
else {
} else {
res.json({
code: "501",
message: "用户失效,请重新登录"
});
}
return headers;
}
exports.uploadFile = function (req, res) {
var headers = getHeader(req, res);
if (req.is("multipart/form-data")) {
var url = [];
for (var key in req.body) {
... ... @@ -172,24 +177,9 @@ function joinimg(url) {
// }
exports.ueditor = function(req, res) {
var headers = {};
if (req.session && req.session.user) {
var ipObject = ipaddr.process(req.ip).octets;
var ip = ipObject ? ipObject.join('.') : req.ip;
var headers = getHeader(req, res);
headers = {
'x-user-id': req.session.user.auth.pid,
'x-user-name': req.session.user.auth.account,
'x-site-type': 1,
'x-client-ip': ip
};
}else{
res.json({
code: "501",
message: "用户失效,请重新登录"
});
}
if (req.is("multipart/form-data")) {
req.body.file = fs.createReadStream(req.files.upfile.path);
req.body.bucket="goodsimg";
... ...