node-ueditor-qiniu
v0.3.0
Published
在node-ueditor插件上扩展,将存储文件放到七牛上.
Downloads
13
Maintainers
Readme
node-ueditor-qiniu
node+ueditor+qiniu
#####支持
- 图片上传
- 文件上传
- 视频上传
- 涂鸦上传只能保存到七牛
根据node-ueditor插件扩展,将存储文件存放到七牛上.
example
var nuq = require("node-ueditor-qiniu");
nuq.conf.ACCESS_KEY="xxx"; //七牛开发者ACCESS_KEY
nuq.conf.SECRET_KEY="xxxx"; //七牛开发者SECRET_KEY
nuq.conf.urlhost="xxxx"; //七牛访问的域名
nuq.conf.bucket="xxxx"; //七牛对象储存
nuq.conf.savelocal=true; //保存七牛和本地 默认只保存到七牛:false
nuq.conf.imageps="watermark/1/image/aHR0cDovL2RldmVsb3Blci5xaW5pdS5jb20vcmVzb3VyY2UvbG9nby0yLmpwZw==/dissolve/88/gravity/SouthEast/dx/10/dy/10";
app.use(bodyParser.urlencoded({
extended: true
}));
app.use("/ueditor/ue", nuq.ueditor(path.join(__dirname, 'public'), function(req, res, next) {
// ueditor 客户发起上传请求
if(req.query.action.indexOf('upload')===0){
var dir_url = './upload/'; //本地保存路径
res.ue_up(dir_url);
}
// 客户端发起列表请求
else if (req.query.action.indexOf('list')===0){
res.ue_list(req.query.action)
}
// 客户端发起其它请求
else {
res.setHeader('Content-Type', 'application/json');
// 这里填写 ueditor.config.json 这个文件的路径
res.redirect('/ueditor/config.json')
}}));
完整代码
var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
// var nuq = require("node-ueditor-qiniu");
var nuq = require("node-ueditor-qiniu");
nuq.conf.ACCESS_KEY="xxx";
nuq.conf.SECRET_KEY="xxxx";
nuq.conf.urlhost="xxxx"; //七牛访问的域名
nuq.conf.bucket="xxxx";
nuq.conf.savelocal=true; //保存七牛和本地 默认只保存到七牛:false
nuq.conf.imageps="watermark/1/image/aHR0cDovL2RldmVsb3Blci5xaW5pdS5jb20vcmVzb3VyY2UvbG9nby0yLmpwZw==/dissolve/88/gravity/SouthEast/dx/10/dy/10";
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));
//ueditor访问的地址
app.use("/ueditor/ue", nuq.ueditor(path.join(__dirname, 'public'), function(req, res, next) {
// ueditor 客户发起上传请求
if(req.query.action.indexOf('upload')===0){
var dir_url = './upload/'; //本地保存路径
res.ue_up(dir_url);
}
// 客户端发起获取列表请求
else if (req.query.action.indexOf('list')===0){
res.ue_list(req.query.action) // 客户端会列出所有文件
}
// 客户端发起其它请求
else {
res.setHeader('Content-Type', 'application/json');
// 这里填写 ueditor.config.json 这个文件的路径
res.redirect('/ueditor/config.json')
}}));
app.get('/ueditor', function(req,res){
res.render("ueditor");
});
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});
升级日志
v0.3.0 涂鸦上传
支持涂鸦上传只支持七牛
v0.2.0 添加图片处理,详情参照
conf.imageps:string //图片处理 不处理传空
v0.1.0 添加文件保存到本地
conf.savelocal:boolean //是否保存到本地 默认保存到七牛(false)