Skip to content

Commit d86198a

Browse files
authored
feat(files): add presigned URL generation support for execution files (#1980)
1 parent 785f847 commit d86198a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

apps/sim/lib/uploads/contexts/execution/execution-file-manager.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { createLogger } from '@/lib/logs/console/logger'
2-
import { getBaseUrl } from '@/lib/urls/utils'
32
import { isUserFile } from '@/lib/utils'
43
import type { UserFile } from '@/executor/types'
54
import 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

Comments
 (0)