diff --git a/src/main/java/io/github/devopsws/demo/config/WebSecurityConfig.java b/src/main/java/io/github/devopsws/demo/config/WebSecurityConfig.java index 91eba00..d388450 100644 --- a/src/main/java/io/github/devopsws/demo/config/WebSecurityConfig.java +++ b/src/main/java/io/github/devopsws/demo/config/WebSecurityConfig.java @@ -9,7 +9,6 @@ import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.provisioning.InMemoryUserDetailsManager; import org.springframework.security.web.SecurityFilterChain; -import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import static org.springframework.security.config.Customizer.withDefaults; diff --git a/src/main/java/io/github/devopsws/demo/service/FileService.java b/src/main/java/io/github/devopsws/demo/service/FileService.java new file mode 100644 index 0000000..03090f9 --- /dev/null +++ b/src/main/java/io/github/devopsws/demo/service/FileService.java @@ -0,0 +1,31 @@ +package io.github.devopsws.demo.service; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import io.github.devopsws.demo.model.Message; + +@RestController +@RequestMapping("/upload") +public class FileService { + @PostMapping("/") + public Message upload(@RequestParam("file") MultipartFile file) { + System.out.println("Received file uploading request"); + Message message = new Message(); + if (!file.isEmpty()) { + try { + System.out.println("Uploading file size:" + file.getSize()); + + message.setMessage("ok"); + } catch (Exception e) { + message.setMessage(e.getMessage()); + } + } else { + message.setMessage("file is empty"); + } + return message; + } +}