This topic was automatically generated from Slack. You can find the original thread here.
Hello,
I am getting the following error from the one drive upload new file action:
TypeError
Cannot read properties of undefined (reading 'ext')
DETAILS
at Object.run (file:///tmp/__pdg__/dist/code/a1aafce9d85221e893cc06df06052a0b0b24e152098a9b40b1a3aea7b572f655/code/actions/upload-file/upload-file.mjs:60:56)
at null.executeComponent (/var/task/launch_worker.js:242:22)
at MessagePort.messageHandler (/var/task/launch_worker.js:748:28)
Here is the node.js code that creates the file:
import fs from "fs";
import { file } from 'tmp-promise';
// To use previous step data, pass the `steps` object to the run() function
export default defineComponent({
async run({ steps, $ }) {
// Assuming these variables hold markdown-formatted content
const yaml = steps.formatter.$return_value.yaml;
const title = steps.formatter.$return_value.title;
const summary = steps.formatter.$return_value.summary;
const additionalInfo = steps.formatter.$return_value.additional_info;
const transcript = steps.formatter.$return_value.transcript;
// Combine them into one markdown string, add markdown formatting as needed
const markdownContent = `${yaml}
# ${title}
## Summary
${summary}
## Additional Information
${additionalInfo}
## Transcript
${transcript}`;
function sanitizeFilename(filename) {
// Define a regex pattern that matches disallowed characters
const invalidChars = /[:"\/\\|?*]+/g;
// Replace any sequence of invalid characters with a single dash
const cleanFilename = filename.replace(invalidChars, '-');
return cleanFilename;
}
// Define the filename
const markdownFilename = sanitizeFilename(title);
// Step 3: Write the JSON string to a file
const { path: tempFilePath, cleanup } = await file({postfix: '.md' });
//await fs.promises.appendFile(tempFilePath, markdownContent).catch(console.error);
await fs.promises.writeFile(tempFilePath, Buffer.from(markdownContent));
// Now, tempFilePath holds the path to the file which you can use elsewhere
console.log(tempFilePath);
const results = {
tempFilePath: tempFilePath,
title: markdownFilename
}
// Return data to use it in future steps
return results
},
})
How can I fix this? I just entered the parameters as requested.