Socket
Socket
Sign inDemoInstall

ueditor

Package Overview
Dependencies
153
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

example/app.js

11

index.js

@@ -1,2 +0,2 @@

var Busboy = require('Busboy');
var Busboy = require('busboy');
var fs = require('fs');

@@ -6,2 +6,3 @@ var fse = require('fs-extra');

var path = require('path');
var snowflake = require('node-snowflake').Snowflake;
var ueditor = function(static_url, handel) {

@@ -71,9 +72,11 @@ return function(req, res, next) {

res.ue_up = function(img_url) {
var dir = static_url + img_url;
var tmpdir = path.join(os.tmpDir(), path.basename(filename));
var name = snowflake.nextId() + path.extname(tmpdir);
var dest = path.join(static_url, img_url, name);
file.pipe(fs.createWriteStream(tmpdir));
fse.move(tmpdir, static_url + img_url, function(err) {
fse.move(tmpdir, dest, function(err) {
if (err) throw err;
res.json({
'url': img_url,
'url': path.join(img_url, name),
'title': req.body.pictitle,

@@ -80,0 +83,0 @@ 'original': filename,

{
"name": "ueditor",
"decription": "nodejs for ueditor",
"author": "Night_elf",
"version": "1.0.0",
"author": {
"name": "Night_elf"
},
"version": "1.1.0",
"dependencies": {
"busboy": "^0.2.9",
"fs-extra": "^0.11.0"
"fs-extra": "^0.11.0",
"node-snowflake": "0.0.1"
},

@@ -15,3 +18,2 @@ "repository": {

"main": "index.js",
"readmeFilename": "README.md",
"description": "",

@@ -22,6 +24,25 @@ "bugs": {

"homepage": "https://github.com/netpi/ueditor",
"_id": "ueditor@0.0.7",
"_id": "ueditor@1.0.0",
"scripts": {},
"_shasum": "8e42a31397cc742a3b243dd96381f8e59bde1cd3",
"_from": "ueditor@"
"_shasum": "28993ad1dbde8b1d83452400b1c77398f18e630e",
"_from": "ueditor@^1.0.0",
"gitHead": "2538eb8e109572939df8b8a02623f53aaf4e0de4",
"_npmVersion": "1.4.14",
"_npmUser": {
"name": "netpi",
"email": "hellonewworld@vip.qq.com"
},
"maintainers": [
{
"name": "netpi",
"email": "hellonewworld@vip.qq.com"
}
],
"dist": {
"shasum": "28993ad1dbde8b1d83452400b1c77398f18e630e",
"tarball": "http://registry.npmjs.org/ueditor/-/ueditor-1.0.0.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/ueditor/-/ueditor-1.0.0.tgz",
"readme": "ERROR: No README data found!"
}

@@ -22,2 +22,3 @@ #Node.js : ueditor

var bodyParser = require('body-parser')

@@ -30,3 +31,6 @@ var ueditor = require("ueditor")

app.use("/ueditor", ueditor(path.join(__dirname, 'public'), function(req, res, next) {
// /ueditor 入口地址配置 https://github.com/netpi/ueditor/blob/master/example/public/ueditor/ueditor.config.js
// 官方例子是这样的 serverUrl: URL + "php/controller.php"
// 我们要把它改成 serverUrl: URL + 'ue'
app.use("/ueditor/ue", ueditor(path.join(__dirname, 'public'), function(req, res, next) {

@@ -36,5 +40,12 @@ // ueditor 客户发起上传图片请求

if(req.query.action === 'uploadimage'){
// 这里你可以获得上传图片的信息
var foo = req.ueditor;
var img_url = 'yourpath'; // 填写你要把图片保存的路径 ( path.join(__dirname, 'public') 是根路径)
res.ue_up(img_url); // 执行保存图片 并且返回给客户端信息
console.log(foo.filename); // exp.png
console.log(foo.encoding); // 7bit
console.log(foo.mimetype); // image/png
// 下面填写你要把图片保存到的路径 ( 以 path.join(__dirname, 'public') 作为根路径)
var img_url = 'yourpath';
res.ue_up(img_url); //你只要输入要保存的地址 。保存操作交给ueditor来做
}

@@ -44,3 +55,3 @@ // 客户端发起图片列表请求

var dir_url = 'your img_dir'; // 要展示给客户端的文件夹路径
res.ue_list(dir_url)
res.ue_list(dir_url) // 客户端会列出 dir_url 目录下的所有图片
}

@@ -52,4 +63,4 @@ // 客户端发起其它请求

// 这里填写 ueditor.config.json 这个文件的路径
res.redirect('/ueditor/ueditor.config.json}
}));
res.redirect('/ueditor/ueditor.config.json')
}}));

@@ -67,11 +78,11 @@ ```

app.use("/ueditor", ueditor(path.join(__dirname, 'public'), function(req, res, next) {
app.use("/ueditor/ue", ueditor(path.join(__dirname, 'public'), function(req, res, next) {
// ueditor 客户发起上传图片请求
if(req.query.action === 'uploadimage'){
var foo = req.ueditor;
var date = new Data();
var date = new Date();
var imgname = req.ueditor.filename;
var img_url = '/images/ueditor/'+date.getTime()+imgname;
res.ue_up(img_url); // 执行保存图片 并且返回给客户端信息
res.ue_up(img_url); //你只要输入要保存的地址 。保存操作交给ueditor来做
}

@@ -81,13 +92,14 @@ // 客户端发起图片列表请求

var dir_url = '/images/ueditor/';
res.ue_list(dir_url)
res.ue_list(dir_url); // 客户端会列出 dir_url 目录下的所有图片
}
// 客户端发起其它请求
else {
res.setHeader('Content-Type', 'application/json');
res.redirect('/ueditor/ueditor.config.json}
}));
res.redirect('/ueditor/ueditor.config.json')
}}));
```
你可以来[ueditor:nodejs](http://blog.netpi.me/nodejs/ueditor_nodejs)给作者留言
你可以来[ueditor:nodejs](http://blog.netpi.me/nodejs/ueditor-nodejs)给作者留言
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc