-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathai.svgupgenascii.sbsd3tl.js
36 lines (30 loc) · 1.24 KB
/
ai.svgupgenascii.sbsd3tl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.nio.file.*;
@RestController
public class ImageUploadController {
@PostMapping("/upload")
public String handleFileUpload(@RequestParam("file") MultipartFile file, @RequestParam("title") String title) {
// Check if the file is coming from the correct page
if (!"ASCII Generator SVG".equals(title)) {
throw new IllegalArgumentException("File must be uploaded from the 'ASCII Generator SVG' page.");
}
// Save the file somewhere
Path path = Paths.get("uploads/" + file.getOriginalFilename());
try {
Files.write(path, file.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
// Convert the image to ASCII art
String asciiArt = convertImageToAsciiArt(path);
// Return the ASCII art
return asciiArt;
}
private String convertImageToAsciiArt(Path imagePath) {
// This is where you would add your ASCII art generation code.
// There are Java libraries available that can do this, or you could write your own.
return "";
}
}
// using Spring Boot for the server and Thymeleaf for the HTML template and ascii-art server-side D3.js library