Skip to content

Instantly share code, notes, and snippets.

@grimmerk
Last active April 8, 2018 15:42
Show Gist options
  • Save grimmerk/3de0cdddba9a7312ea1bb623a9b556dc to your computer and use it in GitHub Desktop.
Save grimmerk/3de0cdddba9a7312ea1bb623a9b556dc to your computer and use it in GitHub Desktop.
In Node.js, save JavaScript String as a UTF-8 encoding file in Parse.File system (parseplatform)
const e = require('text-encoding'); //it is built-in for some browsers. We neeed to install it in Node.js
const uint8array = new e.TextEncoder().encode(stringData);
const normalArray = Array.prototype.slice.call(uint8array);
// http://docs.parseplatform.org/js/guide/#creating-a-parsefile
const file = new Parse.File(fileName, normalArray);
file.save().then(function() {
// The file has been saved to Parse.
}, function(error) {
// The file either could not be read, or could not be saved to Parse.
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment