Skip to content

Commit 5d9a9c1

Browse files
committed
新增:上传自定义uploadServiceUpload
1 parent bb92452 commit 5d9a9c1

8 files changed

Lines changed: 31 additions & 36 deletions

File tree

_src/plugins/autoupload.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ UE.plugin.register("autoupload", function () {
103103

104104
var upload = function (file) {
105105
if(me.getOpt('uploadServiceEnable')){
106-
var service = me.getOpt('uploadService');
107-
service.upload('image', file, {
106+
me.getOpt('uploadServiceUpload')('image', file, {
108107
success: function( res ) {
109108
successHandler( res );
110109
},

_src/plugins/simpleupload.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ UE.plugin.register("simpleupload", function () {
7676

7777
var upload = function (file) {
7878
if(me.getOpt('uploadServiceEnable')){
79-
var service = me.getOpt('uploadService');
80-
service.upload('image', file, {
79+
me.getOpt('uploadServiceUpload')('image', file, {
8180
success: function( res ) {
8281
successHandler( res );
8382
},

dialogs/attachment/attachment.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,8 @@
171171
compress: false
172172
};
173173
if(editor.getOpt('uploadServiceEnable')) {
174-
var service = editor.getOpt('uploadService');
175174
uploaderOption.customUpload = function (file, callback) {
176-
service.upload('attachment', file, {
175+
editor.getOpt('uploadServiceUpload')('attachment', file, {
177176
success: function( res ) {
178177
callback.onSuccess(file, {_raw:JSON.stringify(res)});
179178
},

dialogs/audio/audio.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,8 @@
385385
};
386386

387387
if(editor.getOpt('uploadServiceEnable')) {
388-
var service = editor.getOpt('uploadService');
389388
uploaderOption.customUpload = function (file, callback) {
390-
service.upload('audio', file, {
389+
editor.getOpt('uploadServiceUpload')('audio', file, {
391390
success: function( res ) {
392391
callback.onSuccess(file, {_raw:JSON.stringify(res)});
393392
},

dialogs/image/image.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,8 @@
435435
} : false
436436
};
437437
if(editor.getOpt('uploadServiceEnable')) {
438-
var service = editor.getOpt('uploadService');
439438
uploaderOption.customUpload = function (file, callback) {
440-
service.upload('image', file, {
439+
editor.getOpt('uploadServiceUpload')('image', file, {
441440
success: function( res ) {
442441
callback.onSuccess(file, {_raw:JSON.stringify(res)});
443442
},

dialogs/scrawl/scrawl.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,9 +654,8 @@ function exec(scrawlObj) {
654654
};
655655

656656
if(editor.getOpt('uploadServiceEnable')) {
657-
var service = editor.getOpt('uploadService');
658657
var file = utils.base64toBlob(base64, 'image/png');
659-
service.upload('image', file, {
658+
editor.getOpt('uploadServiceUpload')('image', file, {
660659
success: function( res ) {
661660
if (!scrawlObj.isCancelScrawl) {
662661
successHandler(res);

dialogs/video/video.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,8 @@
438438
compress: false
439439
};
440440
if(editor.getOpt('uploadServiceEnable')) {
441-
var service = editor.getOpt('uploadService');
442441
uploaderOption.customUpload = function (file, callback) {
443-
service.upload('video', file, {
442+
editor.getOpt('uploadServiceUpload')('video', file, {
444443
success: function( res ) {
445444
callback.onSuccess(file, {_raw:JSON.stringify(res)});
446445
},

ueditor.config.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -185,28 +185,30 @@
185185
}
186186

187187
// 自定义上传功能
188-
, uploadServiceEnable: true
189-
// 自定义上传配置
190-
, uploadService: {
191-
upload: function(type, file, callback, option ) {
192-
console.log('upload', type, file, callback, option);
193-
var i = 0;
194-
var call = function(){
195-
i++;
196-
if(i > 3){
197-
callback.success({
198-
"state": "SUCCESS",
199-
"url": "https://ms-assets.modstart.com/demo/modstart.jpg",
200-
})
201-
return;
202-
}
203-
setTimeout(function(){
204-
callback.progress(0.3 * i);
205-
call();
206-
},500);
207-
}
208-
call();
209-
}
188+
, uploadServiceEnable: false
189+
// 自定义上传函数,需要在这个函数中实现自定义上传逻辑
190+
// type 上传类型,image 图片,video 视频,audio 音频,attachment 附件
191+
// file 文件对象
192+
// callback 回调函数,需要在上传完成后调用 callback.success、callback.error、callback.progress
193+
// option 上传配置,其他一些未来扩展配置
194+
, uploadServiceUpload: function(type, file, callback, option ) {
195+
console.log('uploadServiceUpload', type, file, callback, option);
196+
// var i = 0;
197+
// var call = function(){
198+
// i++;
199+
// if(i > 3){
200+
// callback.success({
201+
// "state": "SUCCESS",
202+
// "url": "https://ms-assets.modstart.com/demo/modstart.jpg",
203+
// })
204+
// return;
205+
// }
206+
// setTimeout(function(){
207+
// callback.progress(0.3 * i);
208+
// call();
209+
// },500);
210+
// }
211+
// call();
210212
}
211213

212214
// 插入图片自定义配置

0 commit comments

Comments
 (0)