fix the fix
This commit is contained in:
parent
f60d5f2114
commit
98711948b6
@ -26,20 +26,20 @@ public class IndexController {
|
|||||||
this.pasteService = pasteService;
|
this.pasteService = pasteService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/")
|
||||||
|
public String home() {
|
||||||
|
return "index";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is to allow for Hastebin compatibility.
|
* This is to allow for Hastebin compatibility.
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/documents")
|
@PostMapping(value = "/documents")
|
||||||
public ResponseEntity<?> uploadPaste(@RequestBody String content, @RequestHeader(HttpHeaders.CONTENT_TYPE) String contentType) {
|
public ResponseEntity<?> uploadPaste(@RequestBody String content, @RequestHeader(value = HttpHeaders.CONTENT_TYPE, required = false) String contentType) {
|
||||||
String id = pasteService.createPaste(content, contentType);
|
String id = pasteService.createPaste(content, contentType);
|
||||||
return ResponseEntity.ok(Map.of("key", id));
|
return ResponseEntity.ok(Map.of("key", id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/")
|
|
||||||
public String home() {
|
|
||||||
return "index";
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
public String paste(@PathVariable String id, Model model) {
|
public String paste(@PathVariable String id, Model model) {
|
||||||
try {
|
try {
|
||||||
|
@ -56,7 +56,7 @@ public class PasteService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the paste content type is valid.
|
// Ensure the paste content type is valid.
|
||||||
if (contentType.contains("image") || contentType.contains("video") || contentType.contains("audio")) {
|
if (contentType != null && (contentType.contains("image") || contentType.contains("video") || contentType.contains("audio"))) {
|
||||||
log.info("Paste content type is not supported. (content type: {})", contentType);
|
log.info("Paste content type is not supported. (content type: {})", contentType);
|
||||||
throw new BadRequestException("The paste content type is not supported, not uploading...");
|
throw new BadRequestException("The paste content type is not supported, not uploading...");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user