There's tons of documentation on Internet how to send a file stream in HTTP POST request in other languages, but not in Scalatra.
To the topic: I'd like to send an image as byte array or as a file stream (sorry for sloppy terminology, I'm an absolute newbie) via Scalatra post(). I already have backend Java functions that take byte array, convert it back to .jpg image and store it on the server. What I'm unclear on is the exact syntax how to do this in Scalatra.
That's what my post request looks like:
val imageInBytes = ... //obtain image in bytes
post("/images", ("image" -> imageInBytes))
However, Eclipse says that overloaded method post cannot be applied to (String, (String, Array[Byte]))
On the server side:
post("/images"){
contentType = "image/jpeg" //for displaying the image
val imInBytes = params("image") //obtain data from request body
//do something with it.
}
Any help would be greatly appreciated!