fgrehm / letter_opener_web

A web interface for browsing Ruby on Rails sent emails
MIT License
719 stars 113 forks source link

Add support for storing letters and attachments on AWS s3 #129

Open pdabrowski6 opened 9 months ago

pdabrowski6 commented 9 months ago

Hello @fgrehm 👋 I added support to store letters and attachments on S3 bucket. Thanks to this solution it is possible to use the gem on Heroku when there are multiple workers. It will also help on containerized applications. This PR solves the issue reported in https://github.com/fgrehm/letter_opener_web/issues/35

I attached to the README details how to setup the bucket on s3 and the content of the policy required to safely manage the bucket and delete files.

ismaelbks commented 7 months ago

Hello, is there any chance this PR would be merged ? This would be very useful because we use LetterOpener for all of our platforms (~50) and we are switching to dockerized about so without this we would need to use something else than LetterOpener 🥲

qdegraeve commented 7 months ago

Nice feature , maybe it would be better for s3 management to add an option to specify a prefix to store the files inside the bucket so it would be easy and safe to create a lifecylcle policy for automatic cleanup.

fgrehm commented 6 months ago

@stevenharman any thoughts on this?

stevenharman commented 6 months ago

I certainly understand the desire for this feature. However, I worry about adding aws-sdk-s3 as a dependency for everyone. I think we could get around this with some use of Ruby autoload and explicit instructions for adding that dependency.

Or, perhaps more work but a better overall approach, would be to make the "backend" pluggable. The default backend, which ships with this Gem, is local disk storage, like today. But an extension (e.g., letter_opener_web-s3) could provide an alternate backend for storing, receiving messages and attachments.

That would require some effort to formalize the API/contract of "backend," but I don't think that'd be a too bad. Thoughts?