Tag: enyo

如何使用webOS上的Node.js服务将图像二进制数据写入本地文件系统?

我正在尝试使用Node.js将从Evernote getResourceData -method收到的图像数据写入JavaScript代码的本地系统。 图像文件已成功保存,但看起来像损坏了,我无法打开它。 函数getResourceData用提供的GUID返回资源的二进制数据。 例如,如果这是一个图像资源,这将包含图像的原始位。 原始的hex: http : //i41.tinypic.com/ev8bnr.jpg hex的下载: http : //i41.tinypic.com/10rs7zm.jpg 代码如下: Client.js : var onSuccess = function(resource, transport) { self.showResourceData(resource); //console.log("Got Resource: "+resource); }; NoteStore.getResourceData(onSuccess,this.showAlertMessage.bind(this, "Failed to get Resource"), inSender.getValue()); showResourceData: function(resource) { //Calls WriteFileAssistant service this.$.writeFile.call({ path: "/downloads/logo1.png", content: resource }); } WriteFileAssistant.js : WriteFileAssistant.prototype.run = function(future) { var filePath […]