File tree 1 file changed +15
-11
lines changed
src/components/DragUpload 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -37,18 +37,22 @@ const getFileListFromDataTransferItems = async (items: DataTransferItem[]) => {
37
37
const filePromises : Promise < File [ ] > [ ] = [ ] ;
38
38
for ( const item of items ) {
39
39
if ( item . kind === 'file' ) {
40
- const entry = item . webkitGetAsEntry ( ) ;
41
- if ( entry ) {
42
- filePromises . push ( processEntry ( entry ) ) ;
40
+ // Safari browser may throw error when using FileSystemFileEntry.file()
41
+ // So we prioritize using getAsFile() method first for better browser compatibility
42
+ const file = item . getAsFile ( ) ;
43
+
44
+ if ( file ) {
45
+ filePromises . push (
46
+ new Promise ( ( resolve ) => {
47
+ resolve ( [ file ] ) ;
48
+ } ) ,
49
+ ) ;
43
50
} else {
44
- const file = item . getAsFile ( ) ;
45
-
46
- if ( file )
47
- filePromises . push (
48
- new Promise ( ( resolve ) => {
49
- resolve ( [ file ] ) ;
50
- } ) ,
51
- ) ;
51
+ const entry = item . webkitGetAsEntry ( ) ;
52
+
53
+ if ( entry ) {
54
+ filePromises . push ( processEntry ( entry ) ) ;
55
+ }
52
56
}
53
57
}
54
58
}
You can’t perform that action at this time.
0 commit comments