Skip to content

Commit

Permalink
Use Okio's base64 implementation (#2870)
Browse files Browse the repository at this point in the history
java.util.Base64 is only available on API 26+ on Android while
Okio's implementation works on all API levels.

This fixes #2857
  • Loading branch information
ansman authored Jan 13, 2021
1 parent adbf0c8 commit e64d34c
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import okio.Buffer
import okio.BufferedSink
import okio.BufferedSource
import okio.IOException
import java.util.Base64

/**
* An [OperationMessageSerializer] that uses the format used by
Expand Down Expand Up @@ -112,7 +111,7 @@ class AppSyncOperationMessageSerializer(
private fun Map<String, Any?>.base64Encode(): String {
val buffer = Buffer()
Utils.writeToJson(this, JsonWriter.of(buffer))
return Base64.getUrlEncoder().encodeToString(buffer.readByteArray())
return buffer.readByteString().base64Url()
}
}
}

0 comments on commit e64d34c

Please sign in to comment.