Skip to content

Instantly share code, notes, and snippets.

@yurrriq
Last active August 29, 2015 14:19
Show Gist options
  • Select an option

  • Save yurrriq/61582e7e38dc4f45dcc3 to your computer and use it in GitHub Desktop.

Select an option

Save yurrriq/61582e7e38dc4f45dcc3 to your computer and use it in GitHub Desktop.
Write base64 image data to a file
(refer-clojure :exclude [replace])
(require '[clojure.java.io :refer [output-stream]]
'[clojure.string :refer [replace]])
(import '(org.apache.commons.codec.binary Base64))
(let [src "data:image/png;base64,..."
data (Base64/decodeBase64 (replace src #"^data:image/\w+;base64," ""))
out (output-stream "/path/to/file.png")]
(.write out data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment