@@ -45,8 +45,8 @@ export interface FileUploadOperations {
4545 uploadOneFile : ( file : File ) => Promise < void >
4646 /** Recursively upload files from a directory */
4747 addFromDir : ( dir : FileSystemDirectoryEntry ) => void
48- /** Handle dropped items (files or directories) */
49- handleDroppedItems : ( items : DataTransferItemList ) => void
48+ /** Handle dropped items (files or directories), with optional fallback FileList */
49+ handleDroppedItems : ( items : DataTransferItemList , fallbackFiles ?: FileList ) => void
5050 /** Retry a failed upload */
5151 retryUpload : ( file : File ) => Promise < void >
5252 /** The semaphore used to limit concurrent uploads */
@@ -190,18 +190,29 @@ export function useFileUploadOperations(config: FileUploadOperationsConfig): Fil
190190 )
191191
192192 const handleDroppedItems = useCallback (
193- ( items : DataTransferItemList ) => {
193+ ( items : DataTransferItemList , fallbackFiles ?: FileList ) => {
194+ let handledViaEntry = false
195+
194196 Array . from ( items ) . forEach ( ( item ) => {
195197 const entry = item . webkitGetAsEntry ( )
196198 if ( entry ?. isDirectory ) {
199+ handledViaEntry = true
197200 addFromDir ( entry as FileSystemDirectoryEntry )
198201 } else if ( entry ?. isFile ) {
202+ handledViaEntry = true
199203 const fse = entry as FileSystemFileEntry
200204 fse . file ( ( file ) => {
201205 void uploadOneFile ( file )
202206 } )
203207 }
204208 } )
209+
210+ // Fallback for browsers where webkitGetAsEntry() returns null (e.g., Firefox in some cases)
211+ if ( ! handledViaEntry && fallbackFiles && fallbackFiles . length > 0 ) {
212+ Array . from ( fallbackFiles ) . forEach ( ( file ) => {
213+ void uploadOneFile ( file )
214+ } )
215+ }
205216 } ,
206217 [ addFromDir , uploadOneFile ]
207218 )
0 commit comments