import { NextResponse } from "next/server"; import { deleteVideoFileAction } from "../../../channels/[slug]/videos/[id]/videoActions"; import { ops, opsFail, reqSlug, reqString, reqVideoId } from "../_lib"; export const dynamic = "force-dynamic"; // POST { slug, id, file } // // The video page's Files list delete: one file of one video's directory. It is // deleteVideoFileAction, so it is `removeMediaFile` — a tiered media file goes // with its bytes on the media drive, never as a bare link — and it refuses what // the button refuses: a name that is not one entry of the directory, a file on // a media drive that is not mounted or not answering (nothing is deleted), a // channel whose drive is not answering, something that is not a regular file. // The channel's report is refreshed after. No undo. export async function POST(request: Request) { return ops(request, ["slug", "id", "file"], async (body) => { const res = await deleteVideoFileAction( reqSlug(body, "slug"), reqVideoId(body, "id"), reqString(body, "file"), ); if (!res.ok) return opsFail(res.error); return NextResponse.json({ ok: true }); }); }