@@ -101,7 +101,12 @@ function FilesDownloadDrawer({
101101 return
102102 }
103103 try {
104- const fileBlob = await downloadResourceAsBlob ( item . url ! )
104+ let fileBlob : Blob
105+ if ( item . url instanceof Blob ) {
106+ fileBlob = item . url
107+ } else {
108+ fileBlob = await downloadResourceAsBlob ( item . url ! )
109+ }
105110 if ( item . folderPath === '/' ) {
106111 const fileHandle = await directoryHandle . current . getFileHandle ( item . name , { create : true } )
107112 const writable = await fileHandle . createWritable ( )
@@ -125,11 +130,15 @@ function FilesDownloadDrawer({
125130
126131 const downloadFile = async ( item : DrawerFileItemType ) => {
127132 console . log ( 'downloadFile' , item )
128- const isCross = isCrossOrigin ( item . url ! )
129- let url = item . url !
130- if ( isCross ) {
133+ const isCross = item . url instanceof Blob ? false : isCrossOrigin ( item . url ! )
134+ let url : string = ''
135+ if ( item . url instanceof Blob ) {
136+ url = URL . createObjectURL ( item . url )
137+ } else if ( isCross ) {
131138 const blob = await downloadResourceAsBlob ( item . url ! )
132139 url = URL . createObjectURL ( blob )
140+ } else {
141+ url = item . url !
133142 }
134143 const a = document . createElement ( 'a' )
135144 a . href = url
@@ -138,7 +147,7 @@ function FilesDownloadDrawer({
138147 document . body . appendChild ( a )
139148 a . click ( )
140149 document . body . removeChild ( a )
141- if ( isCross ) URL . revokeObjectURL ( url )
150+ if ( item . url instanceof Blob || isCross ) URL . revokeObjectURL ( url )
142151 }
143152 if ( item . url ) {
144153 if ( canSelectFolder ) {
0 commit comments