feat: Docker部署与CI/CD集成, 搜索栏修复, 上传目录改为data

This commit is contained in:
xiner
2025-11-28 18:42:30 +08:00
commit 8351d6bbfc
243 changed files with 13192 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import fs from 'fs';
import path from 'path';
import { getServerConfig } from '../../../../lib/serverConfig';
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const { name } = req.query;
if (typeof name !== 'string') {
return res.status(400).send('Invalid file name');
}
try {
const baseDir = path.join(process.cwd(), getServerConfig().uploadDir);
const filePath = path.join(baseDir, name);
if (!fs.existsSync(filePath)) {
return res.status(404).send('File not found');
}
const ext = path.extname(filePath).toLowerCase();
const type = ext === '.zip' ? 'application/zip'
: ext === '.mp4' ? 'video/mp4'
: ext === '.webm' ? 'video/webm'
: ext === '.mov' ? 'video/quicktime'
: 'application/octet-stream';
res.setHeader('Content-Type', type);
const stream = fs.createReadStream(filePath);
stream.pipe(res);
} catch (e) {
res.status(500).send('Internal error');
}
}