@@ -124,29 +124,29 @@ public static ImageStore[] make3Drequest() {
124
124
}
125
125
126
126
127
- public static String convertImage (String imageLocation ) {
127
+ public static String convertImage (String imageLocation , String fileName ) {
128
128
String apiUrl = "https://api.meshy.ai/v1/image-to-3d" ;
129
129
RestTemplate restTemplate = new RestTemplate ();
130
130
HttpHeaders headers = new HttpHeaders ();
131
131
headers .setContentType (MediaType .APPLICATION_JSON );
132
132
headers .set ("Authorization" , "Bearer " + AIApplication .THREEDEY );
133
133
String requestJson =
134
134
// "{\"image_url\": \"https://upload.wikimedia.org/wikipedia/commons/e/e1/Face_%E2%80%93_Alexander.jpg\", " +
135
- "{\" image_url\" : \" " +imageLocation +"\" , " +
135
+ "{\" image_url\" : \" " +imageLocation + fileName +"\" , " +
136
136
"\" enable_pbr\" : true, \" surface_mode\" : \" hard\" }" ;
137
137
HttpEntity <String > entity = new HttpEntity <>(requestJson , headers );
138
138
ResponseEntity <String > response = restTemplate .postForEntity (apiUrl , entity , String .class );
139
139
ObjectMapper mapper = new ObjectMapper ();
140
140
try {
141
141
JsonNode root = mapper .readTree (response .getBody ());
142
142
String theResultString = root .path ("result" ).asText ();
143
- return pollApiUntilSuccess (theResultString );
143
+ return pollApiUntilSuccess (fileName , theResultString );
144
144
} catch (IOException e ) {
145
145
e .printStackTrace ();
146
146
return "Error parsing JSON" ;
147
147
}
148
148
}
149
- public static String pollApiUntilSuccess (String theResultString ) {
149
+ public static String pollApiUntilSuccess (String fileName , String theResultString ) {
150
150
RestTemplate restTemplate = new RestTemplate ();
151
151
HttpHeaders headers = new HttpHeaders ();
152
152
headers .set ("Authorization" , "Bearer " + AIApplication .THREEDEY );
@@ -162,7 +162,7 @@ public static String pollApiUntilSuccess(String theResultString) {
162
162
HttpMethod .GET , entity , String .class );
163
163
JsonNode rootNode = mapper .readTree (response .getBody ());
164
164
String status = rootNode .path ("status" ).asText ();
165
- System .out .println ("ORDSCalls.pollApiUntilSuccess status:" + status );
165
+ System .out .println (fileName + " status:" + status );
166
166
if ("SUCCEEDED" .equals (status )) {
167
167
// String modelUrl = rootNode.path("model_url").asText();
168
168
// String modelGlbUrl = rootNode.path("model_urls").path("glb").asText();
0 commit comments