File tree 1 file changed +7
-5
lines changed
src/main/java/com/amadeus/travel
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 6
6
import com .amadeus .resources .Resource ;
7
7
import com .amadeus .resources .TripDetail ;
8
8
import com .google .gson .JsonObject ;
9
- import com .sun .org .apache .xerces .internal .impl .dv .util .Base64 ;
10
-
11
9
import java .io .File ;
10
+ import java .io .FileInputStream ;
12
11
import java .io .IOException ;
13
- import java .nio . file . Files ;
12
+ import java .util . Base64 ;
14
13
15
14
/**
16
15
* <p>
@@ -89,9 +88,12 @@ public TripDetail post(String body) throws ResponseException {
89
88
*/
90
89
public TripDetail post (File file ) throws ResponseException , IOException {
91
90
// 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 );
93
95
JsonObject body = new JsonObject ();
94
- body .addProperty ("payload" , b64Encoded );
96
+ body .addProperty ("payload" , encodedFile );
95
97
96
98
Response response = client .post ("/v3/travel/trip-parser" , body );
97
99
return (TripDetail ) Resource .fromObject (response , TripDetail .class );
You can’t perform that action at this time.
0 commit comments