job description uploads

This commit is contained in:
Om Lanke
2025-09-23 12:36:38 +05:30
parent d171d23471
commit afedb8df6c
3 changed files with 13 additions and 4 deletions

View File

@@ -30,8 +30,8 @@ export async function createJob(formData: FormData) {
if (descriptionFile && descriptionFile.size > 0) {
try {
// Create uploads directory if it doesn't exist
const uploadsDir = join(process.cwd(), 'public', 'uploads', 'job-descriptions');
// Create uploads directory in shared location if it doesn't exist
const uploadsDir = join(process.cwd(), 'shared', 'uploads', 'job-descriptions');
await mkdir(uploadsDir, { recursive: true });
// Generate unique filename

View File

@@ -7,15 +7,20 @@ export async function GET(
request: NextRequest,
{ params }: { params: { filename: string } }
) {
console.log("HELLO WORLD")
try {
const filename = params.filename;
const { filename } = await params;
// Security check - prevent directory traversal
if (filename.includes('..') || filename.includes('/') || filename.includes('\\')) {
return NextResponse.json({ error: 'Invalid filename' }, { status: 400 });
}
const filePath = join(process.cwd(), 'public', 'uploads', 'job-descriptions', filename);
// Look for files in the shared uploads directory (navigate to workspace root)
const workspaceRoot = join(process.cwd(), '..', '..');
const filePath = join(workspaceRoot, 'shared', 'uploads', 'job-descriptions', filename);
console.log('Looking for file at:', filePath);
try {
const fileBuffer = await readFile(filePath);
@@ -37,6 +42,7 @@ export async function GET(
return response;
} catch (error) {
console.error('File not found:', error);
return NextResponse.json({ error: 'File not found' }, { status: 404 });
}
} catch (error) {