mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-06-03 19:25:19 +02:00
* 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
25 lines
810 B
TypeScript
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}"`,
|
|
},
|
|
});
|
|
}
|