@@ -486,25 +486,30 @@ const uploadViaMultipart = async (
486486 throw error
487487 }
488488
489- // boundary-raw-fetch: multipart upload control plane uses action query strings; sequenced with initiate/get-part-urls/abort outside the contract layer
490- const completeResponse = await fetch ( '/api/files/multipart?action=complete' , {
491- method : 'POST' ,
492- headers : { 'Content-Type' : 'application/json' } ,
493- body : JSON . stringify ( { uploadToken, parts : uploadedParts } ) ,
494- signal,
495- } )
489+ let path : string
490+ try {
491+ // boundary-raw-fetch: multipart upload control plane uses action query strings; sequenced with initiate/get-part-urls/abort outside the contract layer
492+ const completeResponse = await fetch ( '/api/files/multipart?action=complete' , {
493+ method : 'POST' ,
494+ headers : { 'Content-Type' : 'application/json' } ,
495+ body : JSON . stringify ( { uploadToken, parts : uploadedParts } ) ,
496+ signal,
497+ } )
498+
499+ if ( ! completeResponse . ok ) {
500+ throw new DirectUploadError (
501+ `Failed to complete multipart upload: ${ completeResponse . statusText } ` ,
502+ 'MULTIPART_ERROR' ,
503+ undefined ,
504+ completeResponse . status
505+ )
506+ }
496507
497- if ( ! completeResponse . ok ) {
508+ ; ( { path } = ( await completeResponse . json ( ) ) as { path : string } )
509+ } catch ( err ) {
498510 await abortMultipart ( )
499- throw new DirectUploadError (
500- `Failed to complete multipart upload: ${ completeResponse . statusText } ` ,
501- 'MULTIPART_ERROR' ,
502- undefined ,
503- completeResponse . status
504- )
511+ throw err
505512 }
506-
507- const { path } = ( await completeResponse . json ( ) ) as { path : string }
508513 return { key, path }
509514}
510515
0 commit comments