Hey all,
I’m trying to utilise Plug.Upload in a Plug only webserver, but I’m having issues with it. If I do the following in the handler:
{:ok, body, conn} <- Plug.Conn.read_body(conn)
and have a test like this:
upload = %Plug.Upload{
path: "test/support/rgb.jpg",
filename: "example.jpg",
content_type: "image/jpeg"
}
conn =
:post
|> conn(path("/file"), file: upload)
|> Server.call(@opts)
assert json_response(conn, 200)
Then the body variable contains simply:
"--plug_conn_test--"
Does anyone have an example or know of one where Plug.Upload is demonstrated with unit test (not in a Phoenix app)?
Many thanks