Skip to content

Commit

Permalink
Merge pull request #143 from hoangr1010/Autofill-profile
Browse files Browse the repository at this point in the history
pdf parsing file from s3
  • Loading branch information
hoangr1010 authored May 28, 2024
2 parents 98fc7ee + 8e85ba7 commit ada4f01
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
26 changes: 26 additions & 0 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"mongoose": "^8.2.3",
"multer": "^1.4.5-lts.1",
"nodemon": "^3.1.0",
"pdf-parse": "^1.1.1",
"serverless": "^3.38.0",
"serverless-http": "^3.2.0",
"supertest": "^6.3.4",
Expand Down
21 changes: 21 additions & 0 deletions server/src/utils/extractPDF.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pdf from "pdf-parse";
import axios from "axios";
export const getResumeFromS3 = async (resume_url) => {
const pdfUrl = resume_url;

const response = await axios.get(pdfUrl, { responseType: "arraybuffer" });
return response.data;
};

const parsePdf = async (filePath) => {
try {
const dataBuffer = await getResumeFromS3(filePath);
const data = await pdf(dataBuffer);

return data.text;
} catch (error) {
console.error("Error parsing PDF:", error);
}
};

export default parsePdf;

0 comments on commit ada4f01

Please sign in to comment.