jeanbmar / payload-s3-upload

Send Payload CMS uploads to Amazon S3
MIT License
56 stars 9 forks source link

Working with imageSizes #4

Closed JeffDess closed 2 years ago

JeffDess commented 2 years ago

Hi, I've used your plugin recently and I had a great experience so far! I've noticed that, while uploading the imageSizes works great, Payload's API would return the local domain instead of the S3 URL (for the sizes only).

I didn't find a good solution with the hook configured on a field level. Even if the correct URL is stored in the database for a particular size, say with the help of a beforeChange hook, the url property would still be overridden on API requests.

I've found the best way to deal with this behavior is to apply the afterRead hook on the collection level instead. So here's my implemention, maybe that can be helpful to others?

jeanbmar commented 2 years ago

Hey, thank you for your contribution! Like for https://github.com/jeanbmar/payload-s3-upload/issues/2, it will be worth managing this in plugin code at some point.