Salman Salman - 4 years ago 576
reST (reStructuredText) Question

MultipartException: Current request is not a multipart request

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

public class MaterialController {

@RequestMapping(value="/upload", method= RequestMethod.POST)
public String handleFileUpload(
@RequestParam("file") MultipartFile file){
String name = "test11";
if (!file.isEmpty()) {
try {
byte[] bytes = file.getBytes();
BufferedOutputStream stream =
new BufferedOutputStream(new FileOutputStream(new File(name + "-uploaded")));
return "You successfully uploaded " + name + " into " + name + "-uploaded !";
} catch (Exception e) {
return "You failed to upload " + name + " => " + e.getMessage();
} else {
return "You failed to upload " + name + " because the file was empty.";

and then i used postman to send a pdf:

enter image description here

But the server crashes with the error:

.MultipartException: Current request is not a multipart request

Again i have found this, and added a

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

<bean id="multipartResolver"

Unfortunately, it still complains with the same error.

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download