job description uploads
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,5 +1,8 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# shared uploads
|
||||
shared/uploads
|
||||
|
||||
# Dependencies
|
||||
node_modules
|
||||
.pnp
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user