File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
src/main/java/io/github/devopsws/demo Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 99import org .springframework .security .core .userdetails .UserDetailsService ;
1010import org .springframework .security .provisioning .InMemoryUserDetailsManager ;
1111import org .springframework .security .web .SecurityFilterChain ;
12- import org .springframework .security .config .annotation .method .configuration .EnableGlobalMethodSecurity ;
1312import org .springframework .security .config .annotation .web .configurers .AbstractHttpConfigurer ;
1413import static org .springframework .security .config .Customizer .withDefaults ;
1514
Original file line number Diff line number Diff line change 1+ package io .github .devopsws .demo .service ;
2+
3+ import org .springframework .web .bind .annotation .PostMapping ;
4+ import org .springframework .web .bind .annotation .RequestMapping ;
5+ import org .springframework .web .bind .annotation .RequestParam ;
6+ import org .springframework .web .bind .annotation .RestController ;
7+ import org .springframework .web .multipart .MultipartFile ;
8+
9+ import io .github .devopsws .demo .model .Message ;
10+
11+ @ RestController
12+ @ RequestMapping ("/upload" )
13+ public class FileService {
14+ @ PostMapping ("/" )
15+ public Message <?> upload (@ RequestParam ("file" ) MultipartFile file ) {
16+ System .out .println ("Received file uploading request" );
17+ Message <String > message = new Message <String >();
18+ if (!file .isEmpty ()) {
19+ try {
20+ System .out .println ("Uploading file size:" + file .getSize ());
21+
22+ message .setMessage ("ok" );
23+ } catch (Exception e ) {
24+ message .setMessage (e .getMessage ());
25+ }
26+ } else {
27+ message .setMessage ("file is empty" );
28+ }
29+ return message ;
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments