From c6a3b3b74f6e7e17f5259ba877ea67cb18d5c57c Mon Sep 17 00:00:00 2001 From: digaus Date: Mon, 16 Mar 2020 17:19:51 +0100 Subject: [PATCH] fix(electron): correct implementation of Filesystem.appendFile (#2567) --- electron/src/electron/filesystem.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/electron/src/electron/filesystem.ts b/electron/src/electron/filesystem.ts index a51f93ee35..66ec7e42e0 100644 --- a/electron/src/electron/filesystem.ts +++ b/electron/src/electron/filesystem.ts @@ -89,7 +89,12 @@ export class FilesystemPluginElectron extends WebPlugin implements FilesystemPlu if(Object.keys(this.fileLocations).indexOf(options.directory) === -1) reject(`${options.directory} is currently not supported in the Electron implementation.`); let lookupPath = this.fileLocations[options.directory] + options.path; - this.NodeFS.appendFile(lookupPath, options.encoding, options.data, (err:any) => { + let data: (Buffer | string) = options.data; + if (!options.encoding) { + const base64Data = options.data.indexOf(',') >= 0 ? options.data.split(',')[1] : options.data; + data = Buffer.from(base64Data, 'base64'); + } + this.NodeFS.appendFile(lookupPath, data, options.encoding || 'binary', (err:any) => { if(err) { reject(err); return;