System Information
- Strapi Version: 4.10.5
- Operating System: MacOS
- Database: PostgreSQL
- Node Version: 18.14
- NPM Version:
- Yarn Version:
I am successfully creating new entry combined with one or more files as described here:
but the issue I am getting that I have a lifecycle event afterCreate that does not see the uploaded files - and I need them immediately in order to send e-mail that includes them.
Data given to the method of course contain only from the records itself (no relations) but since there is an existing record with ID, I can and do easily fetch the record along with relation that I need (“media” field) - but, at this point, this seems to be empty (I get the null instead of a list of images). When I later on (on frontend, refresh the screen to get new data) - media is of course there so the uploads did work.
Is there any way to do this in this lifecycle event or is this some general issue with files uploaded at record creation?
Here is my (work in progress) afterCreate code:
async afterCreate(event) {
const data = event.result
console.log("service.afterCreate - data", data)
if (data.id) {
const existing = await strapi.db.query('api::service.service').findOne({
where: { id: data.id },
populate: ["media"]
})
console.log("service.afterCreate - existing", existing)
}
await sendMail(data, "create")
},