npm install ueditor-nodejs --save
var ueditor = require('ueditor-nodejs'); app.use('/ueditor/ue', ueditor({//这里的/ueditor/ue是因为文件件重命名为了ueditor,如果没改名,那么应该是/ueditor版本号/ue configFile: '/ueditor/php/config.json',//如果下载的是jsp的,就填写/ueditor/jsp/config.json mode: 'bcs', //本地存储填写local accessKey: 'Adxxxxxxx',//本地存储不填写,bcs填写 secrectKey: 'oiUqt1VpH3fdxxxx',//本地存储不填写,bcs填写 staticPath: path.join(__dirname, 'public'), //一般固定的写法,静态资源的目录,如果是bcs,可以不填 dynamicPath: '/blogpicture' //动态目录,以/开头,bcs填写buckect名字,开头没有/.路径可以根据req动态变化,可以是一个函数,function(req) { return '/xx'} req.query.action是请求的行为,uploadimage表示上传图片,具体查看config.json. }));
动态目录示例,这里例子是这个博客中的一段代码,如果是我自己上传图片,就放在uploadimage下,访客的图片放在visitorimage下。dynamicPath参数填写这个函数就可以了。bcs暂不支持自动创建目录操作,所以,返回的bucket必须是存在的,buckect开头没有/。
var dynamicPath = function (req) { if (req.query.action == 'uploadimage') {//如果是上传图片 if (req.session.isMe) {//如果是博主自己 return '/uploadimage' } else {//其余的当作访客 return '/visitorimage' } } }