-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace current base64 #141
Conversation
@@ -89,7 +89,7 @@ public TripDetail post(String body) throws ResponseException { | |||
*/ | |||
public TripDetail post(File file) throws ResponseException, IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I don't know how to use this method even for the original one. I got a long string from the test case, I tried this string on the post(string)
and it works. Then I copy this string and paste it into a pdf file, then try post(file)
but it fails with "com.amadeus.exceptions.ServerException: [500]
Unfortunately your request could not be processed. We are enhancing our system to support this request in future."
@@ -89,7 +89,7 @@ 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())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All I can make sure of is that this new encoding method can get the same result as the original base64 encoding method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @xianqiliu, did you try with this method?
https://docs.oracle.com/javase/8/docs/api/java/util/Base64.html
java.util.Base64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @jabrena, yep I tried that before cause you have already sent me this link last week. But this method requires Java 1.8. Our compile Java is 1.7, and when I tried this method on my IDE, it suggests that I should set my language to 1.8+. So I search for another method that I use in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jabrena
The following is the original code from the JAVA SDK repo's build.gradle
compileJava {
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
}
compileTestJava {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jabrena So from my understanding, the methods we are supposed to use must be compatible with Java 1.7. But I don't know if I misunderstand or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand it.
In that case, we will pause
this PR, because we will review this issue:
#137
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you may be interested in this chat
issues/184#issuecomment-1192926857
Fixes #139
Replace by using DatatypeConverter
Reference: https://stackoverflow.com/questions/21904682/how-to-avoid-warning-for-the-base-64