| Server IP : 217.154.3.148 / Your IP : 216.73.216.90 Web Server : Apache System : Linux blissful-wright.217-154-3-148.plesk.page 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:53:05 UTC 2026 x86_64 User : gracious-boyd_hfhh1h8vo9n ( 10000) PHP Version : 8.3.31 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/gracious-boyd.217-154-3-148.plesk.page/nextjs/app/models/[file]/ |
Upload File : |
import { NextRequest, NextResponse } from 'next/server';
import { createReadStream } from 'node:fs';
import { access, stat } from 'node:fs/promises';
import path from 'node:path';
export const runtime = 'nodejs';
export async function GET(_req: NextRequest, ctx: { params: Promise<{ file: string }> }) {
try {
const params = await ctx.params;
const filename = params?.file;
if (!filename || !/^[\w.-]+\.onnx$/.test(filename)) {
return new NextResponse('Not found', { status: 404 });
}
const filePath = path.join(process.cwd(), 'models', filename);
await access(filePath);
const info = await stat(filePath);
const stream = createReadStream(filePath);
return new NextResponse(stream as any, {
status: 200,
headers: {
'Content-Type': 'application/octet-stream',
'Content-Length': String(info.size),
'Cache-Control': 'public, max-age=31536000, immutable',
},
});
} catch {
return new NextResponse('Not found', { status: 404 });
}
}