Hello,
I’m struggling currently with extracting a binary file from a POST request body.
On the client side I submit a form with a binary file and the enctype=“multipart/form-data”, that seems to work well.
On the server I’m using Oxygen.jl and try to store the binary content into a new file:
@post "/file" function(req)
open(joinpath("..", "data", "filename"),"w") do f
write(f, req.body)
end
return "file uploaded"
end
When I check the file with a Hex editor I see that there are additional bytes before and after the actual file, in my case an image, like multipart-boundry, filename, content-type,…
But req.body
is a Vector{UInt8}
, what is the best practice to extract the payload only? Maybe I’m approaching this problem from the wrong side, but I can’t wrap my head around it.
Thank you for your help!