WriteSync error when saving binary in iOS


Everytime I call the WriteSync function when saving PDF data it produces an error about content.writeToFileAtomically is undefined. WriteSync works fine in Android though.

Here’s my code for saving the PDF file:

var objFile = fs.knownFolders.documents().getFile(fileName);
var data = base64.decode(result.toString(‘base64’));
objFile.writeSync(data, err=>{

This is the exact error I am getting:
Error: Failed to write to file ‘/Users/data/Containers/Data/Application//Documents/1508849519938.pdf’: TypeError: content.writeToFileAtomically is not a function. (In ‘content.writeToFileAtomically(path, true)’, ‘content.writeToFileAtomically’ is undefined)


Having the same exact issue on iOS using the following code:

base64.decodeBinary = function (encoded) {
	return new Buffer(encoded || '', 'base64');

let documents = fs.knownFolders.documents();
let file = documents.getFile("file.pdf");
let contents = base64.decodeBinary(myb64String);
file.writeSync(contents, e=> { error = e; console.log("FILE WRITE ERROR (BINARY): "+ error); })