Hi Ujjwala,
An image is binary data, so you should not transform your bytes into
strings. What you probably want is to get your image bytes from "another
api"
as either one ByteString (it will then all be in your server memory at
once, so
this might be bad) or a stream of chunks, a Source[ByteString, Any] which
you
send back as http resonse body.
Maybe this is enough to lead you in the right direction?
def getImageBytesFromOtherApi(): Source[ByteString, Unit] = ??? // call
your other api and get the bytes
val route =
pathEndOrSingleSlash {
get {
complete(HttpResponse(
StatusCodes.OK,
// media type needs to be the type of the image of course!
entity = HttpEntity(MediaTypes.`image/jpeg`,
getImageBytesFromOtherApi())
))
}
}
--
Johan Andrén
Typesafe - Reactive apps on the JVM
Twitter: @apnylle
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.