upload.js 1.26 KB
var request=require('request');
var fs=require('fs');
var domain = require('../../config/common.js').domain;

exports.uploadFile=function(req,res){
   
    // TODO 代理上传
    // 方法1
    // if(req.is("multipart/form-data")){
    //     req.body.file=fs.createReadStream(req.files[req.body.filename].path);
    //     // if(req.body.type=="batch-import"){
    //     //     request.post({url:domain+'/batch/import',formData:req.body},function optionalCallback(err, httpResponse, body){
    //     //         res.json(JSON.parse(body));
    //     //     });
    //     // }else{
    //     //     request.post({url:domain+'/fileupload/upload',formData:req.body},function optionalCallback(err, httpResponse, body){
    //     //         res.json(JSON.parse(body));
    //     //     });
    //     // }

    //     request.post({url:domain+'/fileupload/upload',formData:req.body},function optionalCallback(err, httpResponse, body){
    //             res.json(JSON.parse(body));
    //         });
        
    // }else{
    //    res.json({code:"500",message:"请求类型错误"});
    // }
    res.json({
            "code":200,
            "data" : "https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=1444256491,538988776&fm=80",
            "message":"success"
    });
    
   
}