import Link from "next/link";
import { getFile } from "@/lib/store";
import { notFound } from "next/navigation";
import CopyLinkButton from "./CopyLinkButton";
function formatBytes(n: number) {
if (n < 1024) return `${n} B`;
if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
return `${(n / 1024 / 1024).toFixed(2)} MB`;
}
export default async function FileDetailPage({
params,
}: {
params: Promise<{ token: string }>;
}) {
const { token } = await params;
const record = await getFile(token);
if (!record) notFound();
const isBackerup = record.type === "backerup";
const downloadUrl = `/api/files/${token}/download`;
return (
← Back to browse
{isBackerup ? (
.backerup
) : (
.json config
)}
{record.originalName}
{record.group && (
{record.group}
)}
{record.displayName ?? record.containerName ?? record.originalName}
{record.image && (
{record.image}
)}
{record.description && (
{record.description}
)}
{/* Metadata grid */}
File size
{formatBytes(record.size)}
Uploaded
{new Date(record.uploadedAt).toLocaleString()}
{record.group && (
Group
{record.group}
)}
{record.containerName && (
Container name
{record.containerName}
)}
{record.image && (
Image
{record.image}
)}
Share token
{token}
{/* Actions */}
{isBackerup && (
Note: This is a full .backerup archive. It may contain volume data
in addition to the container config. Import it into Backerup to restore
or clone the container.
)}
);
}