You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
620 B
23 lines
620 B
3 months ago
|
import { NextResponse } from 'next/server';
|
||
|
import fs from 'fs';
|
||
|
import path from 'path';
|
||
|
|
||
|
const tftpDir = '/var/lib/tftpboot/';
|
||
|
|
||
|
export async function GET() {
|
||
|
try {
|
||
|
const files = fs.readdirSync(tftpDir).map((filename) => {
|
||
|
const filepath = path.join(tftpDir, filename);
|
||
|
const stats = fs.statSync(filepath);
|
||
|
return {
|
||
|
name: filename,
|
||
|
size: stats.size,
|
||
|
};
|
||
|
});
|
||
|
|
||
|
return NextResponse.json({ files });
|
||
|
} catch (error) {
|
||
|
return NextResponse.json({ error: 'Failed to list files' }, { status: 500 });
|
||
|
}
|
||
|
}
|