Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If i'm uploading resume.json file to an api, resume generation is not working without saving that to a temp location #226

Open
chaitanya1019 opened this issue Jul 18, 2019 · 0 comments

Comments

@chaitanya1019
Copy link

I'm using this tool in api in the below way. But how do i get this tool to work without saving the file to a temp location?

const express = require("express");
const bodyParser = require("body-parser");
const multer = require("multer");
const { exec } = require('child_process');

// create express app
const app = express();

// parse requests of content-type - application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }));

// parse requests of content-type - application/json
app.use(bodyParser.json());

// Setup server port
var port = process.env.PORT || 8080;

var upload = multer().single("resume");

// Send message for default URL
app.get("/", (req, res) => {
  res.json({
    message: "Hello World"
  });
});

app.post("/resume", function(req, res) {
  upload(req, res, function(err) {
    if (err instanceof multer.MulterError) {
      // A Multer error occurred when uploading.
      console.log("mult err occured", err);
    } else if (err) {
      // An unknown error occurred when uploading.
      console.log("unknown err occured");
    }
    // Everything went fine.
    console.log(req.file)
    exec(
      "hackmyresume build " + req.file.buffer + " TO out/resume.html out/resume.doc",
      (err, stdout, stderr) => {
        if (err) {
          console.error(`An error occurred: ${err.message}`);
          return;
        } else {
          console.log(`Result: ${stdout}`);
          if (stderr) {
            console.error(`stderr: ${stderr}`);
          }
        }
      }
    );
  });
});

// listen for requests
app.listen(port, () => {
  console.log("Server is listening on port ", port);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant