File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
src/main/java/com/amadeus/travel Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 66import com .amadeus .resources .Resource ;
77import com .amadeus .resources .TripDetail ;
88import com .google .gson .JsonObject ;
9- import com .sun .org .apache .xerces .internal .impl .dv .util .Base64 ;
10-
119import java .io .File ;
10+ import java .io .FileInputStream ;
1211import java .io .IOException ;
13- import java .nio . file . Files ;
12+ import java .util . Base64 ;
1413
1514/**
1615 * <p>
@@ -89,9 +88,12 @@ public TripDetail post(String body) throws ResponseException {
8988 */
9089 public TripDetail post (File file ) throws ResponseException , IOException {
9190 // Base64 encode file and create request body
92- String b64Encoded = Base64 .encode (Files .readAllBytes (file .toPath ()));
91+ FileInputStream fileInputStreamReader = new FileInputStream (file );
92+ byte [] bytes = new byte [(int )file .length ()];
93+ fileInputStreamReader .read (bytes );
94+ String encodedFile = Base64 .getEncoder ().encodeToString (bytes );
9395 JsonObject body = new JsonObject ();
94- body .addProperty ("payload" , b64Encoded );
96+ body .addProperty ("payload" , encodedFile );
9597
9698 Response response = client .post ("/v3/travel/trip-parser" , body );
9799 return (TripDetail ) Resource .fromObject (response , TripDetail .class );
You can’t perform that action at this time.
0 commit comments