From 1a2f7e86647c966dcc36c906a8be79e9c96bd1d8 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Wed, 17 Aug 2022 17:08:28 +0200 Subject: [PATCH] @uppy/utils: fix drop of multiple files on Chromium browsers (#3998) Fixes: https://github.com/transloadit/uppy/issues/3988 (cherry picked from commit 8ed98725c5d0dc5216e25eb21a145a0c4fd0a496) --- .../src/getDroppedFiles/utils/webkitGetAsEntryApi/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/@uppy/utils/src/getDroppedFiles/utils/webkitGetAsEntryApi/index.js b/packages/@uppy/utils/src/getDroppedFiles/utils/webkitGetAsEntryApi/index.js index 8db7fb029e..4b6c9a17fb 100644 --- a/packages/@uppy/utils/src/getDroppedFiles/utils/webkitGetAsEntryApi/index.js +++ b/packages/@uppy/utils/src/getDroppedFiles/utils/webkitGetAsEntryApi/index.js @@ -41,10 +41,15 @@ async function* createPromiseToAddFileOrParseDirectory (entry) { } export default async function* getFilesFromDataTransfer (dataTransfer, logDropError) { - for (const item of dataTransfer.items) { + const entries = await Promise.all(Array.from(dataTransfer.items, async item => { const lastResortFile = item.getAsFile() // Chromium bug, see https://github.com/transloadit/uppy/issues/3505. const entry = await item.getAsFileSystemHandle?.() ?? getAsFileSystemHandleFromEntry(item.webkitGetAsEntry(), logDropError) + + return { lastResortFile, entry } + })) + + for (const { lastResortFile, entry } of entries) { // :entry can be null when we drop the url e.g. if (entry != null) { try {