DamonOehlman / filestream

W3C File Reader API streaming interfaces
30 stars 11 forks source link

Use FileReaderSync instead of FileReader in Firefox / when FileReader is not available #16

Open D8207 opened 9 years ago

D8207 commented 9 years ago

As suggested in http://stackoverflow.com/questions/22741478/firefox-filereader-is-not-defined-only-when-called-from-web-worker , FileReader is not available in Web Workers in Firefox, making my browserify'ed web worker script using filestream not work.

DamonOehlman commented 9 years ago

@D8207 I've made a patch in the filereadersync branch. Would you mind modifying your package.json to include this branch and see if it fixes your issue?

This should be possible by adding something like the following to your package.json:

{
 ...
  "dependencies": {
    ...
    "filestream": "DamonOehlman/filestream#filereadersync"
  }
  ...
}
D8207 commented 9 years ago

I'm not sure how to do this; browserify just looks at require() calls and includes specified files into the bundled JavaScript from my node_modules...

DamonOehlman commented 9 years ago

OK, if you haven't yet included filestream into your package.json then just try something like this in the directory:

npm install DamonOehlman/filestream#filereadersync --save
D8207 commented 9 years ago

No luck. This version dismisses the error message, but doesn't work either.

It appears FileReaderSync has a different interface than FileReader: its read* methods return values directly, and no events are triggered. Simply replacing FileReader with FileReaderSync won't work.

DamonOehlman commented 9 years ago

OK - I'll have a bit more of a look at the FileReaderSync docs when I get a chance...