Modify file before it's uploaded

default discord avatar
2 months ago

I want to run some custom transforms on a file before it's uploaded.

Looking at the arguments received in the beforeChange hook, I don't think it's possible to handle it there. Is there a way to do this?


  • default discord avatar
    Alessio 🍣
    last month

    Just a thought: maybe it might work with some kind of beforeChange hook. Because you can actually get all "incoming files" from it. Something like that is being used here:

    Maybe that helps figure something out!

    Might be completely wrong there though


    I don't know the exact solution to this

  • default discord avatar
    last month

    I ended up going that route but was hoping there was a cleaner/proper way. I can access the files but by the time that beforeChange runs, they are already written to disk unfortunately.

    My next step is to disable the local storage and write to the disk myself with the modified files 🤞

  • default discord avatar
    Alessio 🍣
    last month

    that sounds like a good plan tbh!

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!


Connect with the Payload Community on Discord



Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.