My challenge is to save data obtained from the Chrome geolocation API into a text file using the Chrome fileSystem API. However, despite successfully creating a file, it remains empty after the process. To simplify, I attempted to add the string '1234567890' to the file. In the provided code, I included console.log statements to identify the lines of code that are not executing, and it appears that the code is not running from writableFileEntry.createWriter() onwards.
chrome.fileSystem.chooseEntry({type: 'saveFile'}, function(writableFileEntry) {
console.log('writableFileEntry - here');
writableFileEntry.createWriter(function(writer) {
console.log('After writableFileEntry - here');
writer.onerror = errorHandler;
writer.onwriteend = function(e) {
console.log('write complete');
};
console.log('before Blob - here');
writer.write(new Blob(['1234567890'], {type: 'text/plain'}));
}, errorHandler);
});
The contents of the manifest.json file are as follows:
"permissions": ["location","geolocation", "storage", "unlimitedStorage", "fileSystem", "syncFileSystem", {"fileSystem": ["write"]}
],
"app": {
"background": {
"scripts": ["background.js"]
}
},
"sockets": {
"tcp": {
"connect": "localhost:80"
},
"udp": {
"send": "localhost:80"
}
}
Any assistance or recommendations would be greatly appreciated! Thank you, Ofer