mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-19 01:54:02 +00:00
import html
This commit is contained in:
100
node_modules/file.js
generated
vendored
100
node_modules/file.js
generated
vendored
@@ -75,80 +75,44 @@ var File = {
|
||||
callback && callback(attach);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
// var buf = new Buffer(data, 'utf-8');
|
||||
// 读出来
|
||||
var err = fs.writeFile(filePath, data, 'ascii');
|
||||
if(err) {
|
||||
console.log(err);
|
||||
callback(false);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
var exec = require('child_process').exec,
|
||||
last = exec('"/Users/life/Documents/kuaipan/go/go-study/bin/file2" "' + txtPath + '" "' + filePath + '"');
|
||||
// last = exec('ls /');
|
||||
// last.stdout.on('data', function (data) {
|
||||
// console.log('标准输出:' + data);
|
||||
// });
|
||||
last.on('exit', function (code) {
|
||||
console.log('子进程已关闭,代码:' + code);
|
||||
fs.unlink(txtPath);
|
||||
if(!code) {
|
||||
if(isImage) {
|
||||
me._addImage(Common.objectId(), filePath, function(newImg) {
|
||||
newImg.IsImage = true;
|
||||
callback && callback(newImg);
|
||||
});
|
||||
} else {
|
||||
me._addAttach(filePath, fileTitle, callback)
|
||||
}
|
||||
} else {
|
||||
callback(false);
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
/*
|
||||
// console.log(txtPath);
|
||||
// console.log(filePath);
|
||||
// 先写到txt中去, 然后调用命令将.txt -> img
|
||||
var txtPath = filePath + '.txt';
|
||||
var err = fs.writeFileSync(txtPath, data);
|
||||
Common.cmd([txtPath, filePath], function(code) {
|
||||
// console.log('子进程已关闭,代码:' + code);
|
||||
// fs.unlink(txtPath);
|
||||
if(!code) {
|
||||
try {
|
||||
if(isImage) {
|
||||
me._addImage(Common.objectId(), filePath, function(newImg) {
|
||||
newImg.IsImage = true;
|
||||
callback && callback(newImg);
|
||||
});
|
||||
} else {
|
||||
me._addAttach(filePath, fileTitle, callback)
|
||||
}
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
callback(false);
|
||||
}
|
||||
} else {
|
||||
callback(false);
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
// return callback && callback({FileId: Common.objectId(), IsImage: true});
|
||||
|
||||
} catch(e) {
|
||||
console.log("error!!!");
|
||||
console.error(e);
|
||||
}
|
||||
},
|
||||
|
||||
copyFile: function(originPath, isImage, callback) {
|
||||
var me = this;
|
||||
var basePath;
|
||||
if(isImage) {
|
||||
basePath = User.getCurUserImagesPath();
|
||||
} else {
|
||||
basePath = User.getCurUserAttachsPath();
|
||||
}
|
||||
|
||||
var filePathAttr = Common.splitFile(originPath);
|
||||
var fileId = Common.objectId();
|
||||
var newFilename = fileId + '_html_' + '.' + filePathAttr.ext;
|
||||
var newFilePath = basePath + '/' + newFilename;
|
||||
|
||||
Common.copyFile(originPath, newFilePath, function(ret) {
|
||||
if(ret) {
|
||||
if(isImage) {
|
||||
me._addImage(fileId, newFilePath, function(newImg) {
|
||||
newImg.IsImage = true;
|
||||
callback(newImg);
|
||||
});
|
||||
} else {
|
||||
me._addAttach(newFilePath, '', function(attach) {
|
||||
callback(attach);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
callback(false);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
getFileBase64: function(filePath) {
|
||||
try {
|
||||
// read binary data
|
||||
|
Reference in New Issue
Block a user