File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
micro-services/emails-fetcher/src/services/pst Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -433,17 +433,23 @@ export default class PSTEmailsFetcher {
433433 async downloadPSTFromSupabase ( storagePath : string ) {
434434 const { data, error } = await supabaseClient . storage
435435 . from ( PST_FOLDER )
436- . download ( storagePath ) ;
436+ . createSignedUrl ( storagePath , 3600 ) ; // 1 hour timeout
437437
438438 if ( error ) throw error ;
439439
440+ const res = await fetch ( data . signedUrl ) ;
441+
442+ if ( ! res . ok || ! res . body ) {
443+ throw new Error ( `Failed to download PST: ${ res . status } ` ) ;
444+ }
445+
440446 this . localPstFilePath = path . join (
441447 '/tmp' ,
442448 `${ Date . now ( ) } -${ path . basename ( storagePath ) } `
443449 ) ;
444450
445451 const writeStream = fs . createWriteStream ( this . localPstFilePath ) ;
446- await pipeline ( data . stream ( ) , writeStream ) ;
452+ await pipeline ( res . body , writeStream ) ;
447453 this . pstFile = new PSTFile ( this . localPstFilePath ) ;
448454 }
449455
You can’t perform that action at this time.
0 commit comments