D
D
Denis Malinochkin2014-11-17 03:52:41
Node.js
Denis Malinochkin, 2014-11-17 03:52:41

How to properly save files in node-webkit?

Hello **userName**!
I have this problem with saving a file in node-webkit :

  • The file encoding does not change.
  • The file is not completely saved. Out of 6.5k characters, it saves only 3.2k, that is, almost half (observed with files that have more than 2k characters).

I trusted the node-webkit-fdialogs library to save the file . This does not play a special role, since if you use the example given in the node-webkit file dialogs documentation , then the problem is still observed.
The code:
// Save
// ----------------------------------------
// #app-save          -> ID кнопки диалога сохранения.
// #app-function-menu -> ID меню.
// #editor-input      -> ID поля, содержащее введённый текст (textarea).
// ----------------------------------------
// notifier           -> npm node-notifier
// ----------------------------------------
$('#app-save').on("click", function() {
  $('#app-function-menu').toggle();

  var content = $('#editor-input').val();
  var contentBuffer = new Buffer(content, 'utf-8');
  var saveDialog = new fdialogs.FDialog({
    type: 'save',
    accept: ['.md']
  });

  saveDialog.saveFile(contentBuffer, 'utf-8', function(err, filepath) {
    notifier.notify({
      title: 'Title',
      message: 'Message!',
      icon: path.join(__dirname, '../images/brand.png')
    });
  });
});

The problem with the encoding, as I understand it, is not only me, judging by this topic .
I hope the Toster community can help.
PS: Yes, I've read Node.js and node-webkit documentation, as well as articles on the Internet, questions on GitHub and Stack Overflow, so please don't post there just like that :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Malinochkin, 2014-11-21
@DiAsCrafts

The issue will be resolved in node-webkit v0.11.2.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question