Fork me on GitHub
#pedestal
<
2022-06-28
>
kishima16:06:24

Hello, is it possible to receive a request with content-type application/octet-stream and read its body directly as a byte-array? When I perform the request, I receive an HTTPInputOverHttp. I see it is an InputStream and maybe I can convert it in an interceptor, but it seems that it would be possible to receive it directly as a stream (I might be wrong though)

souenzzo18:06:12

(defn get-handler
  [{:keys [^InputStream body]}]
  (let [byte-array (.toByteArray  (with-open [baos (ByteArrayOutputStream.)]
                                    (.transferTo body baos)
                                    baos))]
    ....))
Something like that. In JVM8, you can use (io/copy body baos)