使用nodejs将base64数据生成到本地, nw会崩溃

This commit is contained in:
life
2015-05-22 10:59:24 +08:00
parent a9146b02ae
commit 30c1a54bd5

23
src/node_modules/file.js generated vendored
View File

@@ -48,13 +48,22 @@ var File = {
// return;
try {
var txtPath = filePath + '.txt';
// var err = fs.writeFileSync(filePath, new Buffer(data, 'base64'));
var err = fs.writeFileSync(txtPath, data);
var err = fs.writeFileSync(filePath, new Buffer(data, 'base64'));
if(err) {
return callback(false);
}
if(isImage) {
me._addImage(Common.objectId(), filePath, function(newImg) {
newImg.IsImage = true;
callback && callback(newImg);
});
} else {
me._addAttach(filePath, fileTitle, callback)
}
/*
// var buf = new Buffer(data, 'utf-8');
// 读出来
/*
var err = fs.writeFile(filePath, data, 'ascii');
if(err) {
console.log(err);
@@ -87,8 +96,13 @@ var File = {
}
});
*/
/*
// 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);
@@ -110,6 +124,7 @@ var File = {
callback(false);
}
});
*/
// return callback && callback({FileId: Common.objectId(), IsImage: true});