From 290c0a3404975526c47dbb7e3ed93939a1ea8cba Mon Sep 17 00:00:00 2001 From: xianqiliu Date: Fri, 25 Mar 2022 15:47:47 +0100 Subject: [PATCH 1/2] use DatatypeConverter --- src/main/java/com/amadeus/travel/TripParser.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/amadeus/travel/TripParser.java b/src/main/java/com/amadeus/travel/TripParser.java index 47819a66..e4fa7d4b 100644 --- a/src/main/java/com/amadeus/travel/TripParser.java +++ b/src/main/java/com/amadeus/travel/TripParser.java @@ -6,11 +6,11 @@ import com.amadeus.resources.Resource; import com.amadeus.resources.TripDetail; import com.google.gson.JsonObject; -import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; import java.io.File; import java.io.IOException; import java.nio.file.Files; +import javax.xml.bind.DatatypeConverter; /** *

@@ -89,7 +89,8 @@ public TripDetail post(String body) throws ResponseException { */ public TripDetail post(File file) throws ResponseException, IOException { // Base64 encode file and create request body - String b64Encoded = Base64.encode(Files.readAllBytes(file.toPath())); + //String b64Encoded = Base64.encode(Files.readAllBytes(file.toPath())); + String b64Encoded = DatatypeConverter.printBase64Binary(Files.readAllBytes(file.toPath())); JsonObject body = new JsonObject(); body.addProperty("payload", b64Encoded); From eb4447c8c0e53208b8b2969fbc9adf2fcee09a8e Mon Sep 17 00:00:00 2001 From: xianqiliu Date: Fri, 25 Mar 2022 16:56:41 +0100 Subject: [PATCH 2/2] remove old Base64 --- src/main/java/com/amadeus/travel/TripParser.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/amadeus/travel/TripParser.java b/src/main/java/com/amadeus/travel/TripParser.java index e4fa7d4b..445d12f5 100644 --- a/src/main/java/com/amadeus/travel/TripParser.java +++ b/src/main/java/com/amadeus/travel/TripParser.java @@ -89,7 +89,6 @@ public TripDetail post(String body) throws ResponseException { */ public TripDetail post(File file) throws ResponseException, IOException { // Base64 encode file and create request body - //String b64Encoded = Base64.encode(Files.readAllBytes(file.toPath())); String b64Encoded = DatatypeConverter.printBase64Binary(Files.readAllBytes(file.toPath())); JsonObject body = new JsonObject(); body.addProperty("payload", b64Encoded);