hooks: {
afterChange: [
async ({ doc, operation, req }) => {
// Trigger MediaConvert transcoding when video is created or updated
if (operation === 'create' || operation === 'update') {
if (doc.filename) {
try {
// Update status to 'processing'
await req.payload.update({
collection: 'videos',
id: doc.id,
data: {
convertStatus: 'processing',
},
})
...
part of my upload collection have this code, and i want to update the data after i have submit it. But while the media is uploading this afterchange hook triggers, Thus it throws a not found error (image attached).
but if i remove this afterchange hook, it works.
How do i trigger the hook after it finished uploading?