'How do i stop accessing a file after saving it with electron

I'm currently saving files (blobs) to the file-system. I use the 'fs' package from electron.

This is the current code:

const assetBuffer = Buffer.from(await blob.arrayBuffer());
this.electronService.fs.createWriteStream(filePath).write(assetBuffer);

After saving the file I get an error or warning when I try to open the file. "The file is currently being accessed by another application". So I assume that the write function is still accessing the file in the background and the save is never completely finished.

Is there any way to complete the save completely and open the file afterwards? At the moment it works by restarting the application. But that would not be optimal.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source