Implemented encoding response bytes with Base64
This commit is contained in:
parent
7a6d6055f1
commit
7d69fc9d2d
|
@ -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", "*")
|
||||
|
|
Loading…
Reference in New Issue