@@ -423,6 +423,10 @@ export function useKnowledgeUpload(options: UseKnowledgeUploadOptions = {}) {
423423 return await uploadFileInChunks ( file , presignedData , timeoutMs , fileIndex )
424424 }
425425
426+ if ( presignedOverride ?. directUploadSupported && presignedOverride . presignedUrl ) {
427+ return await uploadFileDirectly ( file , presignedOverride , timeoutMs , controller , fileIndex )
428+ }
429+
426430 return await uploadFileThroughAPI ( file , timeoutMs )
427431 } finally {
428432 clearTimeout ( timeoutId )
@@ -510,7 +514,6 @@ export function useKnowledgeUpload(options: UseKnowledgeUploadOptions = {}) {
510514 if ( event . lengthComputable && fileIndex !== undefined && ! isCompleted ) {
511515 const percentComplete = Math . round ( ( event . loaded / event . total ) * 100 )
512516 setUploadProgress ( ( prev ) => {
513- // Only update if this file is still uploading
514517 if ( prev . fileStatuses ?. [ fileIndex ] ?. status === 'uploading' ) {
515518 return {
516519 ...prev ,
@@ -638,7 +641,6 @@ export function useKnowledgeUpload(options: UseKnowledgeUploadOptions = {}) {
638641 } )
639642
640643 if ( ! partUrlsResponse . ok ) {
641- // Abort the multipart upload if we can't get URLs
642644 await fetch ( '/api/files/multipart?action=abort' , {
643645 method : 'POST' ,
644646 headers : { 'Content-Type' : 'application/json' } ,
@@ -822,9 +824,6 @@ export function useKnowledgeUpload(options: UseKnowledgeUploadOptions = {}) {
822824 }
823825 }
824826
825- /**
826- * Upload files using batch presigned URLs (works for both S3 and Azure Blob)
827- */
828827 /**
829828 * Uploads files in batches using presigned URLs
830829 */
0 commit comments