test/user-journey #3

Merged
zhangxiang merged 142 commits from test/user-journey into dev 2026-04-12 13:17:03 +08:00
Showing only changes of commit 1777dd1606 - Show all commits
+6 -2
View File
@@ -3,6 +3,10 @@ import { existsSync } from 'fs';
import path from 'path'; import path from 'path';
import { nanoid } from 'nanoid'; import { nanoid } from 'nanoid';
function getWorkingDirectory(): string {
return process.cwd();
}
export interface UploadOptions { export interface UploadOptions {
maxSize?: number; maxSize?: number;
allowedTypes?: string[]; allowedTypes?: string[];
@@ -130,7 +134,7 @@ export async function uploadFile(
const uploadBaseDir = process.env.UPLOAD_DIR || './uploads'; const uploadBaseDir = process.env.UPLOAD_DIR || './uploads';
const datePath = getDatePath(); const datePath = getDatePath();
const uploadDir = path.join(process.cwd(), uploadBaseDir, type, datePath); const uploadDir = path.join(getWorkingDirectory(), uploadBaseDir, type, datePath);
if (!existsSync(uploadDir)) { if (!existsSync(uploadDir)) {
await mkdir(uploadDir, { recursive: true }); await mkdir(uploadDir, { recursive: true });
@@ -184,7 +188,7 @@ export async function getFileInfo(filePath: string) {
createdAt: stats.birthtime, createdAt: stats.birthtime,
modifiedAt: stats.mtime, modifiedAt: stats.mtime,
}; };
} catch (error) { } catch {
return null; return null;
} }
} }