mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-16 08:01:53 +00:00
switch account
This commit is contained in:
25
node_modules/file.js
generated
vendored
25
node_modules/file.js
generated
vendored
@@ -180,6 +180,31 @@ var File = {
|
||||
}
|
||||
},
|
||||
|
||||
// tinymce 或 mceeditor上传图片
|
||||
// callback({FileId: "xx"})
|
||||
uploadImage: function(imagePath, callback) {
|
||||
var me = this;
|
||||
// 读取文件, 查看是否是图片
|
||||
var filePathAttr = Common.splitFile(imagePath);
|
||||
var ext = filePathAttr.ext;
|
||||
if(!Common.isImageExt(ext)) {
|
||||
return callback(false, 'Please select a image');
|
||||
}
|
||||
var fileId = Common.objectId();
|
||||
// 复制到图片文件夹
|
||||
filePathAttr.nameNotExt = fileId + '_cp_';
|
||||
var newFilename = fileId + '.' + ext;
|
||||
var newFilePath = User.getCurUserImagesPath() + '/' + newFilename;
|
||||
// 复制之, 并写入到数据库中
|
||||
Common.copyFile(imagePath, newFilePath, function(ret) {
|
||||
if(ret) {
|
||||
me._addImage(fileId, newFilePath, callback);
|
||||
} else {
|
||||
callback(false);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 附件操作
|
||||
addAttach: function(filePaths, noteId, callback) {
|
||||
if(!noteId || !filePaths) {
|
||||
|
Reference in New Issue
Block a user