Last active
April 8, 2018 15:42
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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