1
13import { generateThumbs } from "../generateThumbs.js";
14import type { FilePipelineContext, ThumbsResult } from "../types.js";
15
16export async function thumbnailsStep(
17 ctx: FilePipelineContext,
18 finalMime: string
19): Promise<ThumbsResult> {
20 const { job } = ctx;
21 const fileRow = await ctx.prisma.file.findUniqueOrThrow({ where: { id: job.fileId } });
22
23 const { artifacts, primaryKey } = await generateThumbs({
24 sourcePath: ctx.temp.path,
25 mime: finalMime,
26 workspaceId: fileRow.workspaceId,
27 fileId: job.fileId,
28 name: fileRow.name,
29 ...(ctx.extracted.dimensions ? { sourceWidth: ctx.extracted.dimensions.width } : {})
30 });
31
32 for (const a of artifacts) {
33 await ctx.s3Thumbs.putObject(a.key, a.body, a.mime);
34 }
35
36 return { primaryKey, keys: artifacts.map((a) => a.key) };
37}
38