filer.js
filer.js copied to clipboard
Getting an error while creating simple persistent file
I'm writing a Chrome extension and added below code in content script. I'm getting the following error:
Error in event handler for runtime.onMessage: Error: Filesystem has not been initialized. at Object.Filer.create (chrome-extension://fgagghgfkjlcgiamgopcfoomblpnglko/filer.js:616:13)
var filer = new Filer();
filer.init({persistent: true, size: 1024 * 1024}, function(fs) {
// filer.size == Filer.DEFAULT_FS_SIZE
// filer.isOpen == true
// filer.fs == fs
}, onError);
filer.create('/home/myFile.txt', false, function(fileEntry) {
// fileEntry.name == 'myFile.txt'
}, onError);
This might have something to do with the extension permission model. The content script lives in its own world (origin). Can you create the FS within the extension context and message pass between it and the content script?
I'm getting this error, too.
edit: Nevermind. Saw this error in the extensions manager:
'fileSystem' is only allowed for packaged apps, but this is a extension.