I'm trying to simulate drag and drop event with a directory.
What I excatly want to do is convert canvas into file, put it into directory and dispatch drag event.
All of it is done by extension that works on specyfic site. I can drop there directory "img" with "icon.png" manually from file explorer. Drag data is being handled on that site by webkitGetAsEntry().
Works similar to example on this site.
Here's how I can simulate dropping just 1 file:
const canvas = document.createElement("canvas");
const ctx = canvas.getContext('2d');
ctx.fillStyle = "white";
ctx.fillRect(0, 0, 50, 50);
canvas.toBlob(function(blob) {
let dataTransfer = new DataTransfer();
let file = new File([blob], "icon.png");
dataTransfer.items.add(file);
document.querySelector(".drop-zone").dispatchEvent(new DragEvent('drop', {dataTransfer}));
});
But how to make webkitGetAsEntry see dropped data as directory? For example /img/icon.png