5

i want to use the synchroneous JS FileSystem API, therefore, this code has to be put to a webworker. the incoming data for the webworker are taken from a dragndrop event (dataTransfer.items) in order to be able to use chromes newest capabilitiy to upload folders. sadly, every try is canceled by chrome with a "Uncaught Error: DATA_CLONE_ERR: DOM Exception 25".

basically, its like this:

  var files=e.dataTransfer.items; [copying the DataTransferItemList]
  var worker=new Worker(...)
  worker.postMessage(files);

this does not work. any idea, why? a similar (but not 100% identical) example can be found here: http://www.html5rocks.com/en/tutorials/file/filesystem-sync/ - this seems to work. its not a DataTransferItemList, its a FileList there - cant this type of List be serialized?

Thanks, Christoph

  • See http://stackoverflow.com/questions/7506635/uncaught-error-data-clone-err-dom-exception-25-thrown-by-web-worker – pd40 Dec 27 '12 at 11:03
  • This is an interesting question. But for starter, you don't copy object by assigning it to different variable. That rule applies to all languages using garbage collector. And you can only post a string or byte array to web worker - but I hope there will be a solution in the future. – Tomáš Zato Dec 03 '14 at 02:33
  • possible duplicate of [Can the synchronous file system api be used in a chrome extension](http://stackoverflow.com/questions/10493337/can-the-synchronous-file-system-api-be-used-in-a-chrome-extension) – Paul Sweatte Dec 26 '14 at 17:37

1 Answers1

0

You should use event.dataTransfer.files to get the FileList. then you can post that directly to the worker:

var files=e.dataTransfer.files || e.target.files; // Cross browser FileList
var worker=new Worker(...);
worker.postMessage({files: files});
Stefan
  • 3,962
  • 4
  • 34
  • 39