Spring Boot 1.4.3. When downloading files more than 15MB, HTTP 405 pops up and even Exception does not throw ... Mysql max_allowed_packet = 100mb;
spring.http.multipart.max-file-size=50MB spring.http.multipart.max-request-size=50MB @PostMapping("addPost/{name}&{post}&{title}") public String addPost(@PathVariable String name, @PathVariable TypePost post,@PathVariable String title, @RequestParam String contractor,@RequestParam String note, @RequestParam ("files") List<MultipartFile>files){ log.info("\n\nPOST: /admin/addPost/"+name+" "+post+" "+title+'&'+contractor+'&'+note); Message message = new Message(false); DocumentType type = service.getDocumentType(post, title); if(type==null){ List<TypePost>types = new ArrayList<>(); if(post==TypePost.INPUT||post==TypePost.OUTPUT){ types.add(TypePost.INPUT); types.add(TypePost.OUTPUT); }else { types.add(TypePost.CORPORATION); } type = new DocumentType(title); type.setTypes(types); service.addDocumentType(type); } Document document = new Document(type); service.addDocument(document); if (!multipartToFileConverter(files, document)) { message.setText("Сталася помилка. Повторіть, будь ласка, спробу!"); log.info("\n\nReturn: "+gson.toJson(message)); return gson.toJson(message); } document.setNote(note); System.out.println(); System.out.println("Hello!"); Project project = service.getProject(name); long curDate = new Date(System.currentTimeMillis()).getTime(); System.out.println("Hello!"); try{ if(post.equals(TypePost.CORPORATION)){ long postSize = service.getCorporationPostList(project).size()+1; CorporationPost cPost = new CorporationPost(postSize, TypePost.CORPORATION, curDate); System.out.println("Hello!"); cPost.setProject(project); System.out.println("Hello!"); cPost.setDocument(document); System.out.println("Hello!"); service.addCorporationPost(cPost); System.out.println("Hello!"); }else if(post.equals(TypePost.INPUT)){ long postSize = service.getInputPostList(project).size()+1; InputPost iPost = new InputPost(postSize, TypePost.INPUT,curDate, document, project); Contractor contractor2 = service.getContractor(contractor); if(contractor2==null){ contractor2 = new Contractor(contractor); service.addContractor(contractor2); iPost.setContractor(contractor2); }else{ iPost.setContractor(contractor2); } service.addInputPost(iPost); }else{ long postSize = service.getOutputPostList(project).size()+1; OutputPost oPost = new OutputPost(postSize, TypePost.OUTPUT,curDate, document, project); Contractor contractor2 = service.getContractor(contractor); if(contractor2==null){ oPost.setContractor(new Contractor(contractor)); }else{ oPost.setContractor(contractor2); } service.addOutputPost(oPost); } message = new Message(true,"Кореспонденцію успішно додано."); }catch (Exception e) { log.warn(e.getMessage()); message.setText("Сталася помилка. Повторіть, будь ласка, спробу!"); } log.info("\n\nReturn: "+gson.toJson(message)); return gson.toJson(message); } private boolean multipartToFileConverter(List<MultipartFile>mFiles,Document document) throws RuntimeException { List<File>files = new ArrayList<>(); try { for(int i=0;i<mFiles.size();i++){ File file = new File(); file.setPageNumber(i+1); file.setData(mFiles.get(i).getBytes()); file.setType(mFiles.get(i).getContentType()); file.setDocument(document); service.addFile(file); files.add(file); document.getFiles().add(file); } } catch (Exception e) { log.info("\n\n"+e.getMessage()+"\n\n"); return false; } return true; } @Entity @Table(name="documents") public class Document implements Serializable{ @Id @Expose @GeneratedValue private long id; @Expose @Column(columnDefinition="TEXT") private String note; @Expose @OneToOne(fetch = FetchType.EAGER,cascade = CascadeType.ALL) @JoinColumn(name = "type_id") private DocumentType type; @Expose @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY,mappedBy = "document") private List<File>files = new ArrayList<>(); @Expose(serialize=false) @OneToOne(mappedBy="document") private Post post; public Document() {} } @Entity @Table(name="files") public class File implements Serializable{ @Id @Expose @GeneratedValue private long id; @Expose private int pageNumber; @Expose(serialize = false) @Column(columnDefinition="LONGBLOB") private byte[]data; @Expose private String type; @ManyToOne @Expose(serialize=false) @JoinColumn(name = "document_id") private Document document; public File() {} }