Hello, I created a post (https://elixirforum.com/t/downloading-with-user-token) before and I need a Feature which helps me to send a file that be chunked.
Imagine I have big video and my user should download it, I need to chunk this file, mean this file should be cut to multi parts (chunk).
normal Phoenix download
def download(conn, _params) do file = File.read!("/Users/test/name.png") conn |> put_resp_content_type("image/png") |> put_resp_header("Content-disposition","attachment; filename=\"test.png\"") |> put_resp_header("X-Accel-Redirect", "/tempfile/download/test.png") |> put_resp_header("Content-Type", "application/octet-stream") |> send_resp(200, file) end
this is not a stream file, if I change the first line to this:
file = File.stream!("/Users/shahryar/Desktop/Khat-Ghalam.png", , 204800)
I have this error:
no function clause matching in Plug.Conn.resp/3
if I use
|> send_resp(200, file.path) it works sometimes . but I think it isn’t a stream file and I can’t create it many parts.
it should be noted, I wanted to use
|> send_chunked(200) in my phoenix but I have error.
at least I need to create a download file that sends the file as section to section to my user