11import { createLogger } from '@/lib/logs/console/logger'
2- import { getBaseUrl } from '@/lib/urls/utils'
32import { isUserFile } from '@/lib/utils'
43import type { UserFile } from '@/executor/types'
54import type { ExecutionContext } from './execution-file-helpers'
@@ -90,7 +89,9 @@ export async function uploadExecutionFile(
9089 }
9190
9291 try {
93- const { uploadFile } = await import ( '@/lib/uploads/core/storage-service' )
92+ const { uploadFile, generatePresignedDownloadUrl } = await import (
93+ '@/lib/uploads/core/storage-service'
94+ )
9495 const fileInfo = await uploadFile ( {
9596 file : fileBuffer ,
9697 fileName : storageKey ,
@@ -101,16 +102,15 @@ export async function uploadExecutionFile(
101102 metadata, // Pass metadata for cloud storage and database tracking
102103 } )
103104
104- // Generate full URL for file access (useful for passing to external services)
105- const baseUrl = getBaseUrl ( )
106- const fullUrl = `${ baseUrl } /api/files/serve/${ fileInfo . key } `
105+ // Generate presigned URL for file access (10 minutes expiration)
106+ const fullUrl = await generatePresignedDownloadUrl ( fileInfo . key , 'execution' , 600 )
107107
108108 const userFile : UserFile = {
109109 id : fileId ,
110110 name : fileName ,
111111 size : fileBuffer . length ,
112112 type : contentType ,
113- url : fullUrl , // Full URL for external access and downstream workflow usage
113+ url : fullUrl , // Presigned URL for external access and downstream workflow usage
114114 key : fileInfo . key ,
115115 context : 'execution' , // Preserve context in file object
116116 }
0 commit comments