filesystem.html 735 B

12345678910111213141516171819202122232425
  1. <script>
  2. const {ipcRenderer} = require('electron')
  3. function onInitFs (fs) {
  4. fs.root.getFile('log.txt', {create: true}, function (fileEntry) {
  5. fileEntry.createWriter(function (fileWriter) {
  6. var blob = new Blob(['Lorem Ipsum'], {type: 'text/plain'});
  7. fileWriter.onwriteend = function() {
  8. ipcRenderer.send('file-system-write-end')
  9. };
  10. fileWriter.onerror = errorHandler
  11. fileWriter.write(blob);
  12. }, errorHandler);
  13. }, errorHandler);
  14. }
  15. navigator.webkitPersistentStorage.requestQuota(5 * 1024 * 1024, function (granted) {
  16. webkitRequestFileSystem(TEMPORARY, granted, onInitFs, errorHandler);
  17. }, errorHandler)
  18. function errorHandler(e) {
  19. ipcRenderer.send('file-system-error', e)
  20. }
  21. </script>