9

What causes

"DOMException: A URI supplied to the API was malformed, or the resulting Data URL has exceeded the URL length limitations for Data URLs."

at snippet-javascript-console.min.js?

Minimal, verifiable, complete example to demonstrate the issue

var dropzone = document.querySelector("input[type=file]");

dropzone.ondrop = function(e) {

  e.preventDefault();

  var item = e.dataTransfer.items[0].webkitGetAsEntry();

  var directoryReader = item.createReader();
    
  directoryReader.readEntries(
    function(entries) {}
  , function(err) {
      console.error(err);
    }
  );

}
<input type="file" webkitdirectory>

To reproduce use Chrome or Chromium browsers and run stacksnippets and drop a directory at <input type="file"> element. The code does not throw an error at either jsfiddle or plnkr.

0

1 Answer 1

10

This is by design.

Chrome is guarding access to the entries behind a same origin check and our sandbox has a unique origin, as described here. JSFiddle allows same origin requests via sandbox="allow-same-origin", which is why it works there.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .