feat(remote): 完善文件传输功能及WebSocket支持

This commit is contained in:
2026-03-10 01:41:02 +08:00
parent 6d5520dfa5
commit 84e455d9a6
19 changed files with 1263 additions and 5 deletions

View File

@@ -44,7 +44,8 @@ class FileService {
}
getFilePath(filename) {
const filePath = path.join(this.uploadDir, path.basename(filename));
if (!filename) return null;
const filePath = path.normalize(filename);
if (!fs.existsSync(filePath)) {
return null;
}
@@ -92,7 +93,13 @@ class FileService {
mergeChunks(fileId, totalChunks, filename) {
try {
const filePath = path.join(this.uploadDir, path.basename(filename));
const filePath = path.normalize(filename);
const dir = path.dirname(filePath);
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}
const fd = fs.openSync(filePath, 'w');
for (let i = 0; i < totalChunks; i++) {