rowboat/apps/rowboat/app/api/tmp-images/[id]/route.ts
arkml 158777b045
Image (#238)
* added image tool

* show image in playground

* store images in Redis

* new images use unique urls

* moved from redis to s3 for image urls

* removed unnecessary changes

* removed the bubble around assistant messages

* added a download button on hover on image

* increased image size and removed border

* revert the bubbes for the assistant messages
2025-09-11 20:50:20 +05:30

25 lines
810 B
TypeScript

import { NextRequest, NextResponse } from 'next/server';
import { tempBinaryCache } from '@/src/application/services/temp-binary-cache';
export async function GET(request: NextRequest, props: { params: Promise<{ id: string }> }) {
const params = await props.params;
const id = params.id;
if (!id) {
return NextResponse.json({ error: 'Missing id' }, { status: 400 });
}
// Serve from in-memory temp cache
const entry = tempBinaryCache.get(id);
if (!entry) {
return NextResponse.json({ error: 'Not found or expired' }, { status: 404 });
}
return new NextResponse(entry.buf, {
status: 200,
headers: {
'Content-Type': entry.mimeType || 'application/octet-stream',
'Cache-Control': 'no-store',
'Content-Disposition': `inline; filename="${id}"`,
},
});
}