I am trying to send uploaded files as attachment in my email, but I always received this files not exist error kindly help
module.exports = {
async afterCreate(event) {
const { result } = event;
console.log(result);
const filePath = result.signature.url;
console.log("the file path is " + filePath);
if (fs.existsSync(filePath)) {
console.log("file exist");
} else {
console.log("file not exist");
}
attachment = fs.readFileSync(filePath).toString("base64");
try {
console.log(result);
const value = await strapi.plugins["email"].services.email.send({
to: "tluangahauhnar@gmail.com",
from: "webadmin@mzu.edu.in",
subject: "Submission of Application of MZU Registration",
text: "You have sucessfully submitted your application for Mizoram University Registration",
attachments: [
{
filename: "signature",
content: attachment,
type: "application/pdf",
disposition: "attachment",
},
],
});
console.log("the email has been sent");
console.log(value);
} catch (err) {
console.log(err);
}
},
};