Plug.Upload Tests (not Phoenix)

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 =
        |> conn(path("/file"), file: upload)

      assert json_response(conn, 200)

Then the body variable contains simply:


Does anyone have an example or know of one where Plug.Upload is demonstrated with unit test (not in a Phoenix app)?

Many thanks

Anyone? Surely someone has created a Plug.Upload handler and test outside of Phoenix? :slight_smile:

Really lazy answer: search results from this forum.