Getting a blob with cljs-ajax

463 views Asked by At

I am trying to read my ajax response as a blob. The response is present, and can be read with

:response-format ajax.edn/edn-read

for example, but it is in fact an image and I need it as a blob to serve as an <img src='' url. (created with createObjectURL)

I'm not finding an example anywhere, I guess it should be something in the line of :

:response-format {:content-type: "image/jpeg" :read :body :type :blob}

but that's not working...

1

There are 1 answers

0
akond On BEST ANSWER

You probably have to put it that way:

(ns browser
  (:require
[ajax.protocols :refer [-body]]


...

:response-format {:content-type "image/png"
                  :type :blob
                  :description "PNG file"
                  :read -body}