Skip to content

Commit

Permalink
add file upload service
Browse files Browse the repository at this point in the history
  • Loading branch information
LinuxSuRen committed Sep 28, 2024
1 parent 0f8889e commit 9f2953e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/java/io/github/devopsws/demo/service/FileService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.github.devopsws.demo.service;

@RestController
@RequestMapping("/upload")
public class FileService {
@Postmapping("/")
public Message<?> upload(@RequestParam("file") MultipartFile file) {
Message<String> message = new Message<String>();
if (!file.isEmpty()) {
try {
System.out.println("Uploading file size:" + file.length());

message.setMessage("ok");
} catch (Exception e) {
message.setMessage(e.getMessage());
}
} else {
rmessage.setMessage("file is empty");
}
return message
}
}

0 comments on commit 9f2953e

Please sign in to comment.