Skip to content

Commit

Permalink
fix(electron): correct implementation of Filesystem.appendFile (#2567)
Browse files Browse the repository at this point in the history
  • Loading branch information
digaus committed Mar 16, 2020
1 parent 4a29ff8 commit c6a3b3b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion electron/src/electron/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c6a3b3b

Please sign in to comment.