Instead of passing a Base64 string around, create an Express route where we can upload (and later request for viewing) resumes
|
RemoteProcedures.setUserResume = async (userID, base64resume, resumeFilename) => { |
|
resumeFilename = path.parse(resumeFilename).base; // make sure this isn't a path |
|
const userResumePath = getUserResumePath(userID); |
|
if (!existsSync(userResumePath)) { |
|
await fs.mkdir(userResumePath, {recursive: true}); |
|
} else { |
|
const files = await fs.readdir(userResumePath); |
|
await Promise.all( |
|
files.map((f) => fs.unlink(path.resolve(userResumePath, f))) |
|
); |
|
} |
|
if (base64resume){ |
|
const userResumeFilePath = path.join(userResumePath, resumeFilename || "untitled.pdf"); |
|
const bufferData = Buffer.from(base64resume, 'base64'); |
|
await fs.writeFile(userResumeFilePath, bufferData); |
|
} |
|
}; |
|
} |
Instead of passing a Base64 string around, create an Express route where we can upload (and later request for viewing) resumes
khe-revengeance/server/rpc-definitions.ts
Lines 355 to 372 in e0d461e