I have the following code:
def show(conn) do
conn
|> put_resp_header("content-disposition", ~s(attachment; filename="tmp.png"))
|> Plug.Conn.send_file(200, "tmp.png")
end
I'm trying to delete the tmp.png file after sending it, however if I do
def show(conn) do
conn
|> put_resp_header("content-disposition", ~s(attachment; filename="tmp.png"))
|> Plug.Conn.send_file(200, "tmp.png")
File.rm("tmp.png")
end
I'm predictabely told I must return a connection from the controller.
Is there any way of me removing the file after the file is sent?
Thanks in advance