Jump to content

Welcome! You're currently a Guest.

If you'd like to join in the Discussion, or access additional features in our forums, please sign in with your Evernote Account here. Have an Evernote Account but forgot your password? Reset it! Don't have an account yet? Create One! You'll need to set your Display Name before your first post.

Photo
Other

getResourceData: Writing image file

palm evernote

  • Please log in to reply
No replies to this topic

#1 PetroP

PetroP

  • Pip
  • Title: Member
  • Group: Members
  • 7 posts

Posted 28 December 2011 - 01:21 AM

I am trying to write image resource into local system in javascript code using Node.js, the image file is getting saved successfully, but looks like it is corrupted, not able to open it.

Client.js:


var onSuccess = function(resource, transport) {
self.showResourceData(resource);
//console.log("Got Resource: "+resource);
};
enyo.application.NoteStore.getResourceData(onSuccess,this.showAlertMessage.bind(this, "Failed to get Resource"), inSender.getValue());

showResourceData: function(resource) {
//Calls WriteFileAssistant service
this.$.writeFile.call({ path: "/media/internal/downloads/logo1.png", content: resource });
}


WriteFileAssistant.js:


WriteFileAssistant.prototype.run = function(future) {
var filePath = this.controller.args.path;
var content = this.controller.args.content;

var downloadfile = fs.createWriteStream(filePath, {'flags': 'w',encoding: 'binary'});
downloadfile.write(content, encoding='binary', function(err) {
future.result = { path: filePath, bytes: content.length, error: err };
});

}





Please find attached the HEX images of original and downloaded files.

Any help will be greatly appreciated.

-Petro

Attached Files







Also tagged with one or more of these keywords: other, palm, evernote

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users

Clip to Evernote