( payload: UploadTokenPayload, key: string )
| 96 | * from this binding, so every KB object must have one. No-op for other contexts. |
| 97 | */ |
| 98 | const recordKnowledgeBaseOwnership = async ( |
| 99 | payload: UploadTokenPayload, |
| 100 | key: string |
| 101 | ): Promise<void> => { |
| 102 | if (payload.context !== 'knowledge-base' || !payload.workspaceId) { |
| 103 | return |
| 104 | } |
| 105 | await recordKnowledgeBaseFileOwnership({ |
| 106 | key, |
| 107 | userId: payload.userId, |
| 108 | workspaceId: payload.workspaceId, |
| 109 | originalName: payload.fileName ?? key.split('/').pop() ?? key, |
| 110 | contentType: payload.contentType ?? 'application/octet-stream', |
| 111 | size: typeof payload.fileSize === 'number' ? payload.fileSize : 0, |
| 112 | }) |
| 113 | } |
| 114 | |
| 115 | export const POST = withRouteHandler(async (request: NextRequest) => { |
| 116 | try { |
no test coverage detected