How to upload server-generated content to S3 using waffle?

I need to store screenshots, these will go in a postgres table and I was thinking of using waffle-ecto to attach them, and using image transformations to get different versions of the image.

However, I can only find examples on how to do that if the image comes from a multipart form submitted by a user, but in my case I have the contents of the screenshot as a binary as it’s fetched from an external service in the server. What is the proper way of attaching that using waffle?

The same could apply to other server-generated content like charts, csv, pdf… How to attach that using waffle-ecto?

You can make a fake Plug.Upload from the path and use it for Waffle Ecto…


Ah of course! You mean, storing the contents in a temp file and then using it with Plug.Upload. That works, thanks!

You might need to clean up temp file after save… that is what I do with Live Uploads and Waffle Ecto.

1 Like