在javascript中将图片网址添加到数据URI

时间:2015-12-02 15:09:33

标签: javascript file http clojurescript

我要求像这样的图像: http://img0.ndsstatic.com/wallpapers/da9d3d05e8583820ef7337c3dd49c21c_large.jpeg

并希望将响应转换为正确的数据URI

我试图连续那些: “data:”+ respone.headers.content-type +“; base64,”+ response.body

但它不起作用。

(def data (atom ""))

(go (let [res (a/<! (http/get "http://files.parsetfss.com/42a74b87-d8af-4d8b-9bec-be3039f672fe/tfss-247d838f-26c4-4a0e-89b1-793f5165799b-0.jpg"
                              {:with-credentials? false}))]
      (reset! data
              (str "data:" (get-in res [:headers "content-type"]) ";base64," (js/btoa (:body res))))))

0 个答案:

没有答案