feat: add media management (#1337)

* feat: add media management

* feat: add missing page search item

* fix: medias should be hidden for anonymous users

* chore: rename show-all to include-from-all-users

* fix: inconsistent table column for creator-id of media

* fix: schema check not working because of custom type for blob in mysql

* chore: temporarily remove migrations

* chore: readd removed migrations
This commit is contained in:
Meier Lukas
2024-10-26 22:45:32 +02:00
committed by GitHub
parent f8c21f6000
commit db198c6dab
22 changed files with 3762 additions and 5 deletions

View File

@@ -0,0 +1,29 @@
import { notFound } from "next/navigation";
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
import { db, eq } from "@homarr/db";
import { medias } from "@homarr/db/schema/sqlite";
export async function GET(_req: NextRequest, { params }: { params: { id: string } }) {
const image = await db.query.medias.findFirst({
where: eq(medias.id, params.id),
columns: {
content: true,
contentType: true,
},
});
if (!image) {
notFound();
}
const headers = new Headers();
headers.set("Content-Type", image.contentType);
headers.set("Content-Length", image.content.length.toString());
return new NextResponse(image.content, {
status: 200,
headers,
});
}