What the correct way to Phoenix send a new generated file (non text, example gz).
I’m trying with full path (with application dir) or regular path, neither are working.
Tried with File.read! also.
conn
|> put_resp_content_type("application/gzip")
|> put_resp_header("content-disposition", "attachment; filename=#{filename}.gz")
|> send_file(200, full_path)
I can send text files with this:
conn
|> put_resp_content_type(filetype)
|> put_resp_header("content-disposition", "attachment; filename=#{filename}")
|> send_resp(200, content)
The only difference is compress or not:
attr =
case compress do
true ->
:compressed
false ->
:utf8
end
file =
File.open!(temp_file, [:write, attr])
In both cases, file is corrected created at “temp/”, but I still can’t send compressed file.