diff --git a/EpcQrCodeRest/src/main/kotlin/net/codinux/banking/epcqrcode/rest/EpcQrCodeResource.kt b/EpcQrCodeRest/src/main/kotlin/net/codinux/banking/epcqrcode/rest/EpcQrCodeResource.kt index cbca111..9cd343e 100644 --- a/EpcQrCodeRest/src/main/kotlin/net/codinux/banking/epcqrcode/rest/EpcQrCodeResource.kt +++ b/EpcQrCodeRest/src/main/kotlin/net/codinux/banking/epcqrcode/rest/EpcQrCodeResource.kt @@ -11,6 +11,7 @@ import org.eclipse.microprofile.openapi.annotations.parameters.RequestBody import org.eclipse.microprofile.openapi.annotations.responses.APIResponse import org.eclipse.microprofile.openapi.annotations.tags.Tag import org.slf4j.LoggerFactory +import java.util.* import javax.ws.rs.* import javax.ws.rs.core.MediaType import javax.ws.rs.core.Response @@ -23,6 +24,8 @@ class EpcQrCodeResource { protected val epcQrCodeGenerator = EpcQrCodeGenerator() + private val base64Encoder = Base64.getEncoder() + private val log = LoggerFactory.getLogger(EpcQrCodeResource::class.java) @@ -51,7 +54,7 @@ class EpcQrCodeResource { private fun handleJsonRequest(request: GenerateEpcQrCodeRequest): Response { try { val epcQrCode = epcQrCodeGenerator.generateEpcQrCode(mapToEpcQrCodeConfig(request), request.imageHeightAndWidth) - val qrCodeBytes = epcQrCode.bytes // TODO: convert to Base64 + val qrCodeBytes = base64Encoder.encode(epcQrCode.bytes) return Response.ok(GenerateEpcQrCodeResponse(qrCodeBytes)) .header("Access-Control-Allow-Origin", "*")