How to validate a file upload in Workers before saving it to R2?
I've spent ages trying to resolve this. I know how to upload a file and save it to R2. What I can't figure out is best practice to validate the file first.
Lots of resources out there say use something like Formiddable, but I can't believe I need a third-party library just to enforce things like "must be a PDF" or "must be under 100kb".
I know the Workers R2 API allows the stipulation of conditions on PUT operations, but these conditions don't seem to relate to the sort of conditions I mention above.
So what's best practice here?
Lots of resources out there say use something like Formiddable, but I can't believe I need a third-party library just to enforce things like "must be a PDF" or "must be under 100kb".
I know the Workers R2 API allows the stipulation of conditions on PUT operations, but these conditions don't seem to relate to the sort of conditions I mention above.
So what's best practice here?
