Settings manages folders, thumbnail defaults, and passwords for the signed-in account, and choosing an image now browses saved stills instead of only the desktop file dialog. Co-authored-by: Cursor <cursoragent@cursor.com>
20 lines
712 B
TypeScript
20 lines
712 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)
|
|
if (clip.hideThumbnail) {
|
|
throw createError({ statusCode: 404, statusMessage: 'Thumbnail hidden' })
|
|
}
|
|
const path = clipThumbPath(owner, clip.id)
|
|
if (!existsSync(path)) {
|
|
throw createError({ statusCode: 404, statusMessage: 'Thumbnail not found' })
|
|
}
|
|
const buf = readFileSync(path)
|
|
setHeader(event, 'Content-Type', imageContentType(buf))
|
|
setHeader(event, 'Cache-Control', 'private, max-age=3600')
|
|
return buf
|
|
})
|