1
0
mirror of https://github.com/immich-app/immich.git synced 2024-11-27 09:21:05 +02:00

fix(web): upload on file paste (#11922)

This commit is contained in:
Jason Rasmussen 2024-08-20 09:25:26 -04:00 committed by GitHub
parent 3be1aaaaa4
commit 817f42aef7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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';