Returning dynamic file -- not streaming

I’m trying to wrap my head around how Phoenix returns file contents. I see there’s a way to stream a file download (so long as the file is accessible on the server somewhere), but I’m not quite seeing how to serve a dynamic file that’s created on the fly. For educational purposes, I want to do this without streams or chunks.

In pseudo-code, I want something like the following in a controller:

send_content_type_header('content-type: image/jpg')

I can see how to set the proper response headers on the Plug.Con, but I don’t see how to send arbitrary data as the body of the response.

Try this:

send_resp(conn, status, body)

Docs at

1 Like

Whoops – I had this:

no function clause matching in Plug.Conn.resp/3

But I realized I had a tuple inside a tuple. Thank you!