File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -120,27 +120,25 @@ function flatten<T>(items: any[]): T[] {
120
120
] , [ ] ) ;
121
121
}
122
122
123
- function fromDataTransferItem ( item : DataTransferItem , entry ?: FileSystemEntry | null ) {
123
+ async function fromDataTransferItem ( item : DataTransferItem , entry ?: FileSystemEntry | null ) {
124
124
// Check if we're in a secure context; due to a bug in Chrome (as far as we know)
125
125
// the browser crashes when calling this API (yet to be confirmed as a consistent behaviour).
126
126
//
127
127
// See:
128
128
// - https://issues.chromium.org/issues/40186242
129
129
// - https://github.com/react-dropzone/react-dropzone/issues/1397
130
130
if ( globalThis . isSecureContext && typeof ( item as any ) . getAsFileSystemHandle === 'function' ) {
131
- return ( item as any ) . getAsFileSystemHandle ( )
132
- . then ( async ( h : any ) => {
133
- const file = await h . getFile ( ) ;
134
- file . handle = h ;
135
- return toFileWithPath ( file ) ;
136
- } ) ;
131
+ const h = await ( item as any ) . getAsFileSystemHandle ( ) ;
132
+ const file = await h . getFile ( ) ;
133
+ file . handle = h ;
134
+ return toFileWithPath ( file ) ;
137
135
}
138
136
const file = item . getAsFile ( ) ;
139
137
if ( ! file ) {
140
- return Promise . reject ( `${ item } is not a File` ) ;
138
+ throw new Error ( `${ item } is not a File` ) ;
141
139
}
142
140
const fwp = toFileWithPath ( file , entry ?. fullPath ?? undefined ) ;
143
- return Promise . resolve ( fwp ) ;
141
+ return fwp ;
144
142
}
145
143
146
144
// https://developer.mozilla.org/en-US/docs/Web/API/FileSystemEntry
You can’t perform that action at this time.
0 commit comments