Improve media manager UI: search, delete, drag-and-drop, file meta
Local Build and Deploy / deploy (push) Successful in 1m21s

Add a richer media manager with filename search, per-file delete with
confirmation, drag-and-drop uploads, copy-URL feedback, file size/type/date
metadata, and server-side upload validation that returns errors to the UI.
Extend the /api/media listing with size and uploaded timestamps.
This commit is contained in:
openhands committed 2026-07-18 17:29:01 +02:00
1 parent 6a20ccda5c
commit a07d438987
4 files changed
+214 -70

No files matched your search

+9 -4
View File
@@ -10,12 +10,16 @@ import { MEDIA_ROOT, resolveMediaPath } from "@/lib/media-storage";
const MAX_SIZE = 5 * 1024 * 1024; // 5MB
const ALLOWED = ["image/png", "image/jpeg", "image/gif", "image/webp"];
export async function uploadMedia(formData: FormData): Promise<void> {
export async function uploadMedia(
formData: FormData,
): Promise<{ ok: boolean; error?: string }> {
await requirePermission(PERMS.PAGES_EDIT);
const file = formData.get("file") as File | null;
if (!file || file.size === 0) return;
if (file.size > MAX_SIZE) return;
if (!ALLOWED.includes(file.type)) return;
if (!file || file.size === 0) return { ok: false, error: "No file provided" };
if (file.size > MAX_SIZE)
return { ok: false, error: "File too large (max 5MB)" };
if (!ALLOWED.includes(file.type))
return { ok: false, error: "Invalid file type. Allowed: PNG, JPEG, GIF, WebP" };
const baseDir = MEDIA_ROOT;
// eslint-disable-next-line security/detect-non-literal-fs-filename
@@ -31,6 +35,7 @@ export async function uploadMedia(formData: FormData): Promise<void> {
revalidatePath("/api/media");
revalidatePath("/admin/media");
return { ok: true };
}
export async function deleteMedia(name: string): Promise<void> {