I study spray using sprayer and sprayer-httpx (without spray routing) to accept downloaded files. I came up with the following:
def receive = { ... case HttpRequest(POST, Uri.Path("/upload"), _, entity, _) => object mp extends MultipartUnmarshallers mp.MultipartFormDataUnmarshaller(entity).foreach{ part => for{ fname <- part.fields.get("Filename").map(_.entity.asString) fbody <- part.fields.get("Filedata").map(_.entity.buffer) }{ println(fname+ ": " +fbody.length) } } sender ! HttpResponse(status = 200) ... }
This works, but I think Unmarshaller Multipart is not intended to be used that way. Is there a more elegant way to do this?
source share