Giriş
Bir form gönderme içindir. Form içinde json alan gönderileceği gibi dosya da yüklenebilir.Örnek - Dosya İçeren Form
Dosya yükleme için şöyle yaparız
Kod şöyledir
import org.springframework.web.multipart.MultipartFile;
class User {
  public String userId;
  public String emailId;
  public MultipartFile profilePicImageFile;
}
@PostMapping("/upload/post")
public ResponseEntity<String> uploadProfilePic(@ModelAttribute User user) 
  throws Exception {
  
}Örnek - Sadece Form
Şeklen şöyledir
Kod şöyledir
@RestController
@RequestMapping("/")
@AllArgsConstructor
public class NotificationController {
  @GetMapping
  public String sendNotification(@RequestParam String message,
                                 @RequestParam NotificationType notificationType) {
    ...
  }
}Örnek - Sadece Dosya
Dosya yükleme için şöyle yaparız
Kod şöyledir
public List<InputFile> addFile(@RequestParam("files")MultipartFile[] files){
  return fileService.uploadFiles(files);
}


 
Hiç yorum yok:
Yorum Gönder