Skip to content

Commit 1565024

Browse files
committed
feat: add FileSystemFileHandle support
1 parent 1268db8 commit 1565024

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/file-selector.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ function flatten<T>(items: any[]): T[] {
121121
}
122122

123123
function fromDataTransferItem(item: DataTransferItem) {
124+
if ('getAsFileSystemHandle' in DataTransferItem.prototype) {
125+
return item.getAsFileSystemHandle().then((fileSystemHandle: any) => fileSystemHandle.getFile())
126+
.catch((error: { message: any; }) => error.message);
127+
}
124128
const file = item.getAsFile();
125129
if (!file) {
126130
return Promise.reject(`${item} is not a File`);
@@ -185,4 +189,4 @@ async function fromFileEntry(entry: any) {
185189
// https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
186190
interface FileArray extends Array<FileValue> {}
187191
type FileValue = FileWithPath
188-
| FileArray[];
192+
| FileArray[];

0 commit comments

Comments
 (0)