From 817f42aef7c7a659669935909d3ca45c2c516229 Mon Sep 17 00:00:00 2001
From: Jason Rasmussen <jason@rasm.me>
Date: Tue, 20 Aug 2024 09:25:26 -0400
Subject: [PATCH] fix(web): upload on file paste (#11922)

---
 .../drag-and-drop-upload-overlay.svelte       | 22 ++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/web/src/lib/components/shared-components/drag-and-drop-upload-overlay.svelte b/web/src/lib/components/shared-components/drag-and-drop-upload-overlay.svelte
index 935c63500d..e84d2d66f0 100644
--- a/web/src/lib/components/shared-components/drag-and-drop-upload-overlay.svelte
+++ b/web/src/lib/components/shared-components/drag-and-drop-upload-overlay.svelte
@@ -40,11 +40,23 @@
       return handleFiles(dataTransfer.files);
     }
 
-    const transferEntries = Array.from(dataTransfer.items)
-      .map((i: DataTransferItem) => i.webkitGetAsEntry())
-      .filter((i) => i !== null);
-    const files = await getAllFilesFromTransferEntries(transferEntries);
-    return handleFiles(files);
+    const entries: FileSystemEntry[] = [];
+    const files: File[] = [];
+    for (const item of dataTransfer.items) {
+      const entry = item.webkitGetAsEntry();
+      if (entry) {
+        entries.push(entry);
+        continue;
+      }
+
+      const file = item.getAsFile();
+      if (file) {
+        files.push(file);
+      }
+    }
+
+    const directoryFiles = await getAllFilesFromTransferEntries(entries);
+    return handleFiles([...files, ...directoryFiles]);
   };
 
   const browserSupportsDirectoryUpload = () => typeof DataTransferItem.prototype.webkitGetAsEntry === 'function';