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.
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# shared uploads
|
||||||
|
shared/uploads
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
node_modules
|
node_modules
|
||||||
.pnp
|
.pnp
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ export async function createJob(formData: FormData) {
|
|||||||
|
|
||||||
if (descriptionFile && descriptionFile.size > 0) {
|
if (descriptionFile && descriptionFile.size > 0) {
|
||||||
try {
|
try {
|
||||||
// Create uploads directory if it doesn't exist
|
// Create uploads directory in shared location if it doesn't exist
|
||||||
const uploadsDir = join(process.cwd(), 'public', 'uploads', 'job-descriptions');
|
const uploadsDir = join(process.cwd(), 'shared', 'uploads', 'job-descriptions');
|
||||||
await mkdir(uploadsDir, { recursive: true });
|
await mkdir(uploadsDir, { recursive: true });
|
||||||
|
|
||||||
// Generate unique filename
|
// Generate unique filename
|
||||||
|
|||||||
@@ -7,15 +7,20 @@ export async function GET(
|
|||||||
request: NextRequest,
|
request: NextRequest,
|
||||||
{ params }: { params: { filename: string } }
|
{ params }: { params: { filename: string } }
|
||||||
) {
|
) {
|
||||||
|
console.log("HELLO WORLD")
|
||||||
try {
|
try {
|
||||||
const filename = params.filename;
|
const { filename } = await params;
|
||||||
|
|
||||||
// Security check - prevent directory traversal
|
// Security check - prevent directory traversal
|
||||||
if (filename.includes('..') || filename.includes('/') || filename.includes('\\')) {
|
if (filename.includes('..') || filename.includes('/') || filename.includes('\\')) {
|
||||||
return NextResponse.json({ error: 'Invalid filename' }, { status: 400 });
|
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 {
|
try {
|
||||||
const fileBuffer = await readFile(filePath);
|
const fileBuffer = await readFile(filePath);
|
||||||
@@ -37,6 +42,7 @@ export async function GET(
|
|||||||
|
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error('File not found:', error);
|
||||||
return NextResponse.json({ error: 'File not found' }, { status: 404 });
|
return NextResponse.json({ error: 'File not found' }, { status: 404 });
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user