I’m trying to proxy an image. So far I get cannot send_file/5 with null byte
. I am not storing the file though, i just want to proxy the bitstring data
{content_type, image} = case resp do
{:ok, %MachineGun.Response{status_code: status_code, body: body, headers: headers}} when status_code < 300 ->
# TODO: ========================================================
content_type = "image/png"
{content_type, body}
_ ->
{nil, nil} # TODO: FIGURE SOMETHING OUT
end
case {content_type, image} do
{content_type, image} when is_binary(content_type) and is_bitstring(image) ->
conn
|> put_resp_content_type(content_type)
|> send_file(200, image)
_ ->
send_resp(conn, :ok, "")
end