Datatables Editor File upload with Spring Boot

Datatables Editor File upload with Spring Boot

webusr91webusr91 Posts: 12Questions: 5Answers: 0

Hi,

I am trying to support file upload using "Datatables Editor" file upload support to Spring Boot Application.

Following is my Editor config,

var editor = new $.fn.dataTable.Editor( {
    ajax: "/upload1",
    table: "#"+random_str1,
    fields: [ {
        label: "File Title:",
        name: "file_title"
    }, {
        label: "Upload File:",
        name: "flname11",
        type: "upload",
        display: function ( file_id ) {
            return '<img src="'+editor.file( 'files', file_id ).web_path+'"/>';
        },
        clearText: "Clear"
        //noImageText: 'No image'
    }
    ]
 } );

And following is Spring Boot config in Controller,

 @RequestMapping(method = RequestMethod.POST, path = "/upload1",
                  consumes = { MediaType.MULTIPART_FORM_DATA_VALUE },
                  produces = MediaType.APPLICATION_JSON_VALUE)  
   public ResponseEntity<?> handleDataTable_Editor_Request_FileUpload(
    @RequestParam(required = false)  MultipartFile uploadfile, HttpServletRequest request)

   {    
         Note: Here uploadfile is always coming as NULL.
         So i am not getting the file that was uploaded from editor frontend
         wanted to check if any one has solution for this working with Spring Controller

         Actually if i remove "(required = false)" this method is not even called 
                 getting 400 error in browser

   }

and in application.properties have following values,

http.multipart.max-file-size: 128KB 
http.multipart.max-request-size: 128KB
http.multipart.enabled: true
http.multipart.file-size-threshold: 128KB

Can anyone please provide solution or reference here, for getting Datatables editor fileupload working with Spring boot

Thanks

Answers

  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin

    I'm afraid we've not worked with Spring ourselves before, so I can't really help you with the server-side code. Are you able to dump all of the database that is being sent in the request somehow, to check that is was sent?

    For Spring help, you'd probably need to post in a Spring specific forum or StackOverflow.

    Thanks,
    Allan

This discussion has been closed.