Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Modify file before it's uploaded

default discord avatar
_sadajo_2 years ago
3

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?



bump

  • discord user avatar
    alessiogr
    2 years ago

    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:

    https://github.com/payloadcms/plugin-cloud/blob/main/src/hooks/beforeChange.ts#L21

    Maybe that helps figure something out!



    Might be completely wrong there though

    :robotshrug:

    I don't know the exact solution to this

  • default discord avatar
    _sadajo_2 years ago

    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 🤞

  • discord user avatar
    alessiogr
    2 years ago

    that sounds like a good plan tbh!

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.