MultipartException: Current request is not a multipart request

后端 未结 7 991
一整个雨季
一整个雨季 2020-12-13 09:36

I am trying to make a restful controller to upload files. I have seen this and made this controller:

@RestController
public class MaterialController {

             


        
相关标签:
7条回答
  • 2020-12-13 09:41

    When you are using Postman for multipart request then don't specify a custom Content-Type in Header. So your Header tab in Postman should be empty. Postman will determine form-data boundary. In Body tab of Postman you should select form-data and select file type. You can find related discussion at https://github.com/postmanlabs/postman-app-support/issues/576

    0 讨论(0)
  • 2020-12-13 09:41

    In application.properties, please add this:

    spring.servlet.multipart.max-file-size=128KB
    spring.servlet.multipart.max-request-size=128KB
    spring.http.multipart.enabled=false
    

    and in your html form, you need an : enctype="multipart/form-data". For example:

    <form method="POST" enctype="multipart/form-data" action="/">
    

    Hope this help!

    0 讨论(0)
  • 2020-12-13 09:45

    i was facing the same issue with misspelled enctype="multipart/form-data", i was fix this exception by doing correct spelling . Current request is not a multipart request client side error so please check your form.

    0 讨论(0)
  • 2020-12-13 09:46

    in ARC (advanced rest client) - specify as below to make it work Content-Type multipart/form-data (this is header name and header value) this allows you to add form data as key and values you can specify you field name now as per your REST specification and select your file to upload from file selector.

    0 讨论(0)
  • 2020-12-13 09:47

    It looks like the problem is request to server is not a multi-part request. Basically you need to modify your client-side form. For example:

    <form action="..." method="post" enctype="multipart/form-data">
      <input type="file" name="file" />
    </form>
    

    Hope this helps.

    0 讨论(0)
  • 2020-12-13 09:47

    Check the file which you have selected in the request.

    For me i was getting the error because the file was not present in the system, as i have imported the request from some other machine.

    0 讨论(0)
提交回复
热议问题