We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c0a4645 commit 3f41fc5Copy full SHA for 3f41fc5
src/clj_http/lite/util.clj
@@ -27,10 +27,15 @@
27
[unencoded]
28
(URLEncoder/encode unencoded "UTF-8"))
29
30
-(defn base64-encode
+(defmacro base64-encode
31
"Encode an array of bytes into a base64 encoded string."
32
33
- (javax.xml.bind.DatatypeConverter/printBase64Binary unencoded))
+ (if (try (import 'javax.xml.bind.DatatypeConverter)
34
+ (catch ClassNotFoundException _))
35
+ `(javax.xml.bind.DatatypeConverter/printBase64Binary ~unencoded)
36
+ (do
37
+ (import 'java.util.Base64)
38
+ `(.encodeToString (java.util.Base64/getEncoder) ~unencoded))))
39
40
(defn to-byte-array
41
"Returns a byte array for the InputStream provided."
0 commit comments