Skip to content
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

Closed

Conversation

xianqiliu
Copy link
Contributor

@xianqiliu xianqiliu commented Mar 25, 2022

@xianqiliu xianqiliu marked this pull request as ready for review March 25, 2022 16:08
@@ -89,7 +89,7 @@ public TripDetail post(String body) throws ResponseException {
*/
public TripDetail post(File file) throws ResponseException, IOException {
Copy link
Contributor Author

@xianqiliu xianqiliu Mar 28, 2022

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()));
Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

@xianqiliu xianqiliu Mar 30, 2022

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.

Copy link
Contributor Author

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"
}

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor

@steve-donovan steve-donovan Jul 23, 2022

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

@tsolakoua tsolakoua closed this Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace current Base64
4 participants