Yes, I’ve seen that post, but it seems to address a different problem, if I have understood it correctly (uploading a file from one’s computer using a form). I am sending binary data (a tar archive) by http from an Elm app to an Elixir/Phoenix app. The Elm app is sending a POST request with the binary data in the body. I have a dummy controller
def process(conn, params) do
IO.inspect params, label: "params for 'process'"
conn |> render("pdf.json", url: "OK")
end
that receives the data, From the IO.inspect params line, I know that the client and the server are talking to eachother. But the binary data is not in params. From what I’ve read, I think one has to use Plug.Parser, but I am too much of a noob at this point to know what to do.
I guess the real question is how to extract data from the POST request body,
What I need to do is store the binary data in a file, then process it.
Here is what I get on the Elixir side when I make a POST request from the client
[info] OPTIONS /api/print/pdf/harmonic_oscillator!!
[debug] Preflight CORS request from Origin 'http://localhost:8080' is allowed
[info] Sent 200 in 18ms
[info] POST /api/print/pdf/harmonic_oscillator!!
[debug] Simple CORS request from Origin 'http://localhost:8080' is allowed
[debug] Processing with Koko.Web.PrintController.process/2
Parameters: %{"title" => "harmonic_oscillator!!"}
Pipelines: [:api]
params for 'process': %{"title" => "harmonic_oscillator!!"}
[info] Sent 200 in 42ms
Here is the code on the client side that sends the POST request:
sendTarArchiveCmd : String -> List ( String, String ) -> List ( String, Bytes ) -> Cmd DocMsg
sendTarArchiveCmd url stringList dataList =
let
data =
(List.map prepareData dataList) ++ (List.map prepareStringData stringList)
archive : Bytes
archive =
Tar.encodeFiles data |> encode
in
Http.request
{ method = "Post"
, headers = []
, url = url
, body = Http.bytesBody "application/tar" archive
, expect = Http.expectString TexToPdf
, timeout = Nothing
, tracker = Nothing
}


















