In Chrome 32, I've got an JS app where I write raw images from a canvas to a file and I want to close the file and open it for processing in a worker.
I pass the file name to the worker and I can see that it's found and opened but as soon as I try to read it I get a DOM exception (NotFoundError
).
// In my worker:
fs = self.requestFileSystemSync(self.PERSISTENT, quota);
var f = fs.root.getFile(rawFileName, {create: false}); // this works, f is valid
var reader = new FileReaderSync();
// At this point, 'reader' looks ok
rawFramesArrayBuffer = reader.readAsArrayBuffer(f); // My exception is thrown here.
log("Opened " + rawFileName + " for reading.");
In my main thread, I've tried setting my File
and FileWriter
to undefined
to ensure the file is closed (I can't see a method for doing this), but it doesn't help. In any event, the spec says that a NotReadableError
should be thrown if the file is locked, but I don't see this.
If I step through the code, everything pauses for about 5 seconds when I step over the readAsArrayBuffer
line and then the NotFoundError
is thrown.
If I create a DirectoryReader and enumerate all the files, I can see that my file exists.
I needed to access the file via the FileEntry:
rawFramesArrayBuffer = reader.readAsArrayBuffer(f.file());