mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
fix(copilot): fix image auth (#1841)
* Fix copilot image auth * Lint * Remove extra loggign * Update apps/sim/app/api/copilot/chat/route.ts Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
c3436e998f
commit
a31dc733cf
@@ -325,6 +325,7 @@ export async function POST(req: NextRequest) {
|
||||
...(processedFileContents.length > 0 && { fileAttachments: processedFileContents }),
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
logger.info(`[${tracker.requestId}] About to call Sim Agent`, {
|
||||
hasContext: agentContexts.length > 0,
|
||||
|
||||
@@ -122,7 +122,7 @@ export async function verifyFileAccess(
|
||||
}
|
||||
|
||||
// 2. Execution files: workspace_id/workflow_id/execution_id/filename
|
||||
if (inferredContext === 'execution' || isExecutionFile(cloudKey, bucketType)) {
|
||||
if (inferredContext === 'execution' || (!context && isExecutionFile(cloudKey, bucketType))) {
|
||||
return await verifyExecutionFileAccess(cloudKey, userId, customConfig)
|
||||
}
|
||||
|
||||
|
||||
@@ -245,6 +245,11 @@ export async function POST(request: NextRequest) {
|
||||
|
||||
logger.info(`Uploading ${context} file: ${originalName}`)
|
||||
|
||||
// Generate storage key with context prefix and timestamp to ensure uniqueness
|
||||
const timestamp = Date.now()
|
||||
const safeFileName = originalName.replace(/\s+/g, '-')
|
||||
const storageKey = `${context}/${timestamp}-${safeFileName}`
|
||||
|
||||
const metadata: Record<string, string> = {
|
||||
originalName: originalName,
|
||||
uploadedAt: new Date().toISOString(),
|
||||
@@ -258,9 +263,11 @@ export async function POST(request: NextRequest) {
|
||||
|
||||
const fileInfo = await storageService.uploadFile({
|
||||
file: buffer,
|
||||
fileName: originalName,
|
||||
fileName: storageKey,
|
||||
contentType: file.type,
|
||||
context,
|
||||
preserveKey: true,
|
||||
customKey: storageKey,
|
||||
metadata,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user