Skip to content

Commit 5484f58

Browse files
committed
move into javaai dir, add k8s and dockerfile and basicauth
1 parent 85cf448 commit 5484f58

File tree

5 files changed

+227
-22
lines changed

5 files changed

+227
-22
lines changed

java-ai/src/main/java/oracleai/UploadDownloadImage.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,28 @@ public String uploadImage(@RequestParam("image") MultipartFile image, Model mode
4343
private static final String DIRECTORY = "/tmp/images/";
4444

4545
@PostMapping("/uploadimageandvideo")
46-
public ResponseEntity<String> uploadImage(@RequestParam("image") MultipartFile file) throws IOException {
47-
if (file.isEmpty()) {
48-
return ResponseEntity.badRequest().body("Cannot upload empty file");
49-
}
46+
public String uploadimageandvideo(@RequestParam("image") MultipartFile file, Model model) throws IOException {
47+
// public ResponseEntity<String> uploadImage(@RequestParam("image") MultipartFile file, Model model) throws IOException {
48+
// if (file.isEmpty()) {
49+
// return ResponseEntity.badRequest().body("Cannot upload empty file");
50+
// }
5051

5152
try {
5253
org.apache.commons.io.FileUtils.forceMkdir(new File(DIRECTORY));
5354
Path path = Paths.get(DIRECTORY + file.getOriginalFilename());
5455
file.transferTo(path);
55-
return ResponseEntity.ok(
56-
ORDSCalls.convertImage("http://129.80.168.144/transferimage/images/" + file.getOriginalFilename())
57-
);
56+
String fbxUrl = ORDSCalls.convertImage("http://129.80.168.144/transferimage/images/" +
57+
file.getOriginalFilename());
58+
String html = "<a href=\""+fbxUrl+"\">Click here for your FBX 3D model is here.</a>";
59+
model.addAttribute("results", html);
60+
return "resultspage";
61+
// return ResponseEntity.ok(
62+
// ORDSCalls.convertImage("http://129.80.168.144/transferimage/images/" + file.getOriginalFilename())
63+
// );
5864
// return ResponseEntity.ok("File uploaded and available at: " + "/images/" + file.getOriginalFilename());
5965
} catch (Exception e) {
60-
return ResponseEntity.internalServerError().body("Could not upload the file: " + e.getMessage());
66+
return e.toString();
67+
// ResponseEntity.internalServerError().body("Could not upload the file: " + e.getMessage());
6168
}
6269
}
6370

java-ai/src/main/java/oracleai/services/ORDSCalls.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,14 @@ public static String pollApiUntilSuccess(String theResultString) {
164164
String status = rootNode.path("status").asText();
165165
System.out.println("ORDSCalls.pollApiUntilSuccess status:" + status);
166166
if ("SUCCEEDED".equals(status)) {
167-
String modelUrl = rootNode.path("model_url").asText();
168-
String modelGlbUrl = rootNode.path("model_urls").path("glb").asText();
167+
// String modelUrl = rootNode.path("model_url").asText();
168+
// String modelGlbUrl = rootNode.path("model_urls").path("glb").asText();
169169
String modelFbxUrl = rootNode.path("model_urls").path("fbx").asText();
170-
String modelUsdzUrl = rootNode.path("model_urls").path("usdz").asText();
171-
String thumbnailUrl = rootNode.path("thumbnail_url").asText();
172-
return String.format("Model URL: %s\nGLB URL: %s\nFBX URL: %s\nUSDZ URL: %s\nThumbnail URL: %s",
173-
modelUrl, modelGlbUrl, modelFbxUrl, modelUsdzUrl, thumbnailUrl);
170+
// String modelUsdzUrl = rootNode.path("model_urls").path("usdz").asText();
171+
// String thumbnailUrl = rootNode.path("thumbnail_url").asText();
172+
return modelFbxUrl;
173+
// return String.format("Model URL: %s\nGLB URL: %s\nFBX URL: %s\nUSDZ URL: %s\nThumbnail URL: %s",
174+
// modelUrl, modelGlbUrl, modelFbxUrl, modelUsdzUrl, thumbnailUrl);
174175
}
175176
Thread.sleep(1000);
176177
} catch (Exception e) {
Lines changed: 125 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,132 @@
11
<!DOCTYPE html>
2-
<html lang="en">
2+
<html lang="en" xmlns:th="http://www.thymeleaf.org">
33
<head>
44
<meta charset="UTF-8">
5-
<title>Upload Image</title>
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Upload For Digital Doubles</title>
7+
<style>
8+
body {
9+
font-family: Arial, sans-serif;
10+
display: flex;
11+
justify-content: center;
12+
align-items: center;
13+
height: 100vh;
14+
margin: 0;
15+
background-color: #f0f0f0;
16+
}
17+
.container {
18+
text-align: center;
19+
background-color: #fff;
20+
padding: 20px;
21+
border-radius: 10px;
22+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
23+
}
24+
h1 {
25+
color: #333;
26+
}
27+
.form-group {
28+
margin: 15px 0;
29+
}
30+
label {
31+
display: block;
32+
margin-bottom: 5px;
33+
color: #333;
34+
}
35+
input[type="text"],
36+
input[type="email"],
37+
input[type="company"],
38+
input[type="jobrole"],
39+
input[type="tshirtsize"],
40+
input[type="comments"] {
41+
width: 100%;
42+
padding: 10px;
43+
margin: 5px 0 20px 0;
44+
border: 1px solid #ccc;
45+
border-radius: 5px;
46+
box-sizing: border-box;
47+
}
48+
input[type="submit"] {
49+
background-color: #007BFF;
50+
color: white;
51+
border: none;
52+
padding: 15px 30px;
53+
text-align: center;
54+
text-decoration: none;
55+
display: inline-block;
56+
font-size: 16px;
57+
margin: 10px 5px;
58+
border-radius: 5px;
59+
cursor: pointer;
60+
transition: background-color 0.3s;
61+
}
62+
input[type="submit"]:hover {
63+
background-color: #0056b3;
64+
}
65+
</style>
666
</head>
767
<body>
8-
<h1>Upload For Digital Doubles</h1>
9-
<form method="POST" action="/transferimage/uploadimageandvideo" enctype="multipart/form-data">
10-
<label for="image">Select image:</label>
11-
<input type="file" id="image" name="image" accept="image/*" required>
12-
<button type="submit">Upload</button>
13-
</form>
68+
<div class="container">
69+
<h1>Upload Your Image</h1>
70+
71+
<form method="POST" action="/transferimage/uploadimageandvideo" enctype="multipart/form-data">
72+
73+
74+
<div class="form-group">
75+
<label for="image">Select image:</label>
76+
<input type="file" id="image" name="image" accept="image/*" required>
77+
<button type="submit">Upload</button>
78+
79+
<!-- <label for="firstName">First Name:</label>-->
80+
<!-- <input type="text" id="firstName" name="firstName" autocomplete="given-name">-->
81+
</div>
82+
83+
</form>
84+
<!-- -->
85+
<!-- <form method="post" action="http://143.47.96.92/podsofkon/setPlayerNamesAndIds">-->
86+
<!-- &lt;!&ndash; Conditional display for Player 1 Name &ndash;&gt;-->
87+
<!-- <div class="form-group" th:if="${player == 'player1'}">-->
88+
<!-- <label for="player1Name">Player 1 Name:</label>-->
89+
<!-- <input type="text" id="player1Name" name="player1Name" autocomplete="player1Name">-->
90+
<!-- </div>-->
91+
92+
<!-- &lt;!&ndash; Conditional display for Player 2 Name &ndash;&gt;-->
93+
<!-- <div class="form-group" th:if="${player == 'player2'}">-->
94+
<!-- <label for="player2Name">Player 2 Name:</label>-->
95+
<!-- <input type="text" id="player2Name" name="player2Name" autocomplete="player2Name">-->
96+
<!-- </div>-->
97+
98+
<!-- <div class="form-group">-->
99+
<!-- <label for="firstName">First Name:</label>-->
100+
<!-- <input type="text" id="firstName" name="firstName" autocomplete="given-name">-->
101+
<!-- </div>-->
102+
<!-- <div class="form-group">-->
103+
<!-- <label for="lastName">Last Name:</label>-->
104+
<!-- <input type="text" id="lastName" name="lastName" autocomplete="family-name">-->
105+
<!-- </div>-->
106+
<!-- <div class="form-group">-->
107+
<!-- <label for="email">Email:</label>-->
108+
<!-- <input type="email" id="email" name="email" autocomplete="email" required>-->
109+
<!-- </div>-->
110+
<!-- <div class="form-group">-->
111+
<!-- <label for="company">Company:</label>-->
112+
<!-- <input type="text" id="company" name="company" autocomplete="organization">-->
113+
<!-- </div>-->
114+
<!-- <div class="form-group">-->
115+
<!-- <label for="jobrole">Job Role:</label>-->
116+
<!-- <input type="text" id="jobrole" name="jobrole" autocomplete="organization-title">-->
117+
<!-- </div>-->
118+
<!-- <div class="form-group">-->
119+
<!-- <label for="tshirtsize">T-Shirt Size:</label>-->
120+
<!-- <input type="text" id="tshirtsize" name="tshirtsize" autocomplete="tshirt-size">-->
121+
<!-- </div>-->
122+
<!-- <div class="form-group">-->
123+
<!-- <label for="comments">Comments:</label>-->
124+
<!-- <input type="text" id="comments" name="comments" autocomplete="comments">-->
125+
<!-- </div>-->
126+
<!-- <div class="form-group">-->
127+
<!-- <input type="submit" value="Submit">-->
128+
<!-- </div>-->
129+
<!-- </form>-->
130+
</div>
14131
</body>
15132
</html>
47.8 KB
Loading
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<!DOCTYPE html>
2+
<html lang="en" xmlns:th="http://www.thymeleaf.org">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Player Form</title>
7+
<style>
8+
body {
9+
font-family: Arial, sans-serif;
10+
display: flex;
11+
justify-content: center;
12+
align-items: center;
13+
height: 100vh;
14+
margin: 0;
15+
background-color: #f0f0f0;
16+
}
17+
.container {
18+
text-align: center;
19+
background-color: #fff;
20+
padding: 20px;
21+
border-radius: 10px;
22+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
23+
max-width: 90%;
24+
width: 600px;
25+
margin: 20px;
26+
}
27+
h1, h2 {
28+
color: #333;
29+
margin: 15px 0;
30+
}
31+
.image-container {
32+
margin-bottom: 20px;
33+
}
34+
.image-container img {
35+
max-width: 100%;
36+
height: auto;
37+
border-radius: 10px;
38+
display: block;
39+
margin: 0 auto;
40+
}
41+
input[type="submit"] {
42+
background-color: #007BFF;
43+
color: white;
44+
border: none;
45+
padding: 15px 30px;
46+
text-align: center;
47+
text-decoration: none;
48+
display: inline-block;
49+
font-size: 16px;
50+
margin: 10px 5px;
51+
border-radius: 5px;
52+
cursor: pointer;
53+
transition: background-color 0.3s;
54+
}
55+
input[type="submit"]:hover {
56+
background-color: #0056b3;
57+
}
58+
@media (max-width: 600px) {
59+
.container {
60+
width: 100%;
61+
padding: 10px;
62+
}
63+
h1, h2 {
64+
font-size: 18px;
65+
}
66+
input[type="submit"] {
67+
padding: 10px 20px;
68+
font-size: 14px;
69+
}
70+
}
71+
</style>
72+
</head>
73+
<body>
74+
<div class="container">
75+
76+
<h1>Thank You!</h1>
77+
78+
</div>
79+
</body>
80+
</html>

0 commit comments

Comments
 (0)