import { getFile, getPostedFileName } from "@/app/www/logic/file";
import logIP from "@/app/www/media/logIP";

export const GET = logIP(async (req, { params: { fileName } }) => {
  return new Response(
    await getFile(fileName, req.headers.get("X-Real-IP") as string),
    {
      headers: {
        ["content-disposition"]: `attachment; filename="${encodeURI(
          (await getPostedFileName(fileName)) || fileName,
        )}"`,
      },
    },
  );
});
