2017-08-11 55 views

回答

2

使用Strict實體類型:

import akka.util.ByteString 
import akka.http.scaladsl.model.{HttpResponse, MediaTypes,HttpEntity} 

val byteArray : Array[Byte] = ??? 

val body = ByteString(byteArray) 

val entity = HttpEntity.Strict(MediaTypes.`application/octet-stream`, body) 

val httpResponse = HttpResponse(entity = entity) 

complete(httpResponse)