HTTP 500 spring web expo image picker

Viewed 46

I am trying to upload a file in react native using axios to a spring service backend.

  const sf5 = async () => {
    let fd = new FormData();
    fd.append("file", imgimg.uri)
    const eeefile = await instance.post('/uploadfile', {
      body: fd
    }, {headers:{
      "Content-Type": "multipart/form-data"
    }}).then(function (response) {
      //console.log('~~~~~~~~~~~~~~~' + random_val)
      //console.log(response);
    });
  }

However, spring framework is rejecting the request saying

[dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Current request is not a multipart request]

I tried placing a breakpoint in the spring application class. However, request didnt even reach there.

The am able to upload the file from browser through XHR.

Any pointers would be appreciated.

0 Answers
Related