This topic was automatically generated from Slack. You can find the original thread here.
Hi people! Sorry for asking for the same problem i did a days before, but couldn’t solve it. I’m trying to download attachments into /tmp folder, and in the next step, uploading them into a ClickUp task. The thing is that even if the download step succeed, sometimes the upload step could not found any file while doing fs.readdirSync("/tmp")
, i’ve tried adding a delay with the control flow actions, but didn’t work. Here is the code:
• download attachment step:
const fileData = Buffer.from(attachmentData.data, "base64");
fs.writeFileSync(`${TMP_DIR}/${attachment.filename}`, fileData)
console.log(fs.readdirSync(`${TMP_DIR}`)
This step always succeed, and i can verify that the files are being saved in the tmp file
• upload attachment step:
const { TMP_DIR } = steps.define_constants.$return_value;
const taskId = steps.create_task.$return_value;
const files = fs.readdirSync(TMP_DIR).filter(file => file !== "__pdg__" && file !== "__pds__");
console.log("Files in TMP_DIR:", files);
if(files.length){
for(const file of files){
const filePath = `${TMP_DIR}/${file}`;
const fileStream = fs.createReadStream(filePath);
const formData = new FormData();
formData.append(`attachment`, fileStream);
Sometimes, “files” var doesn’t contain the files that was previously saved.
• remove files step:
const files = fs.readdirSync(TMP_DIR).filter(file => file !== "__pdg__" && file !== "__pds__");
for (const file of files) {
const filePath = `${TMP_DIR}/${file}`;
if(fs.existsSync(filePath)){
await fs.promises.unlink(filePath)
console.log(`Deleted file ${file}`);
}