nervgh / angular-file-upload

[ALMOST NOT MAINTAINED] Angular File Upload is a module for the AngularJS framework
MIT License
3.44k stars 1.13k forks source link

"Unsupported Media Type", message: "Content type 'application/octet-stream' not supported" #885

Closed tahoura closed 3 years ago

tahoura commented 3 years ago

hi, i want to upload a user photo with user information. i work with angular6 and spring boot my controller: @PostMapping(value="/new",consumes=MediaType.MULTIPART_FORM_DATA_VALUE) public ResponseEntity createUser(@RequestPart("file") MultipartFile file, @RequestPart User user) throws IOException { if(file.isEmpty()) { return ResponseEntity.notFound().build(); } user.setPhoto(file.getBytes()); userRepository.save(user); return ResponseEntity.ok("user insert"); } my service.ts createUser(user: User,file : File) { const formData = new FormData(); formData.append('file', file); formData.append('user', JSON.stringify(user)); return this.http.post<User>(AppSettings.APP_URL + "/users/new", formData); }