Files
aigen/server/api/library/clips/[id]/video.get.ts
T
towsty ba7a483aac Save each Comfy run as a new clip even if the output filename repeats.
Purging desktop files let MiniMax reuse MiniMax_H3_00001_, so the next job returned the previous clip. Ignore stale events from the last job so a second generate cannot paste the first video over the new one.
2026-08-25 20:29:36 -05:00

17 lines
677 B
TypeScript

import { existsSync, readFileSync } from 'node:fs'
export default defineEventHandler((event) => {
const { owner } = assertLibraryOwner(event)
const id = String(getRouterParam(event, 'id') || '')
const clip = getClip(owner, id)
assertFolderAccess(event, clip.folderId)
const path = clipVideoPath(owner, clip.id)
if (!existsSync(path)) {
throw createError({ statusCode: 404, statusMessage: 'Video file is missing' })
}
setHeader(event, 'Content-Type', 'video/mp4')
setHeader(event, 'Content-Disposition', `inline; filename="${safeDownloadName(clipTitle(clip))}.mp4"`)
setHeader(event, 'Cache-Control', 'private, no-store')
return readFileSync(path)
})