It looks like you’re trying to send a PDF file stored in the /tmp directory to an EdenAI endpoint using a Pipedream component. Based on your code, I have made a few adjustments to ensure it works correctly within a Pipedream workflow:
import { axios } from "@pipedream/platform";
import fs from "fs";
import FormData from "form-data";
export default defineComponent({
props: {
eden_ai: {
type: "app",
app: "eden_ai",
},
filePath: {
type: "string",
label: "Path to the PDF file in /tmp",
},
},
async run({ steps, $ }) {
const form = new FormData();
form.append("providers", "affinda");
form.append("file", fs.createReadStream(this.filePath));
console.log(form);
const response = await axios($, {
method: "POST",
url: "https://api.edenai.run/v2/ocr/resume_parser",
headers: {
Authorization: `Bearer ${this.eden_ai.$auth.api_key}`,
...form.getHeaders(),
},
data: form,
});
return response;
},
});
Make sure to replace steps.download_file_to_tmp.$return_value[1] with the this.filePath prop, which you can set to the path of the PDF file in the /tmp directory when configuring the step in your workflow.
I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double check my answers and code! Learn how to build your own.