-
-
Save fmnoise/14f860b0885c9e2a7d0b6c3967d6d1c7 to your computer and use it in GitHub Desktop.
Image URL to Base64 String in Clojure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; REPL ONLY | |
;; Require clj-http https://github.com/dakrone/clj-http/ | |
(require '[clj-http.client :as client]) | |
;; Import Apache Common's Base64 encoder/decoder | |
(import (org.apache.commons.codec.binary Base64)) | |
(def test-file | |
;Image Credit Metropolitan Museum of Art | |
(client/get "http://images.metmuseum.org/CRDImages/ma/web-large/DP241865.jpg" {:as :byte-array})) | |
(def imgBase64Str | |
(String. (Base64/encodeBase64 (:body test-file)))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment