Skip to content

Error uploading multiple files on a multipart request using webflux #13268

@fjavierjimenez

Description

@fjavierjimenez

I'm migrating a rest service developed with spring-boot 2 to use webflux. This rest service is used to upload 2 files using multipart. The first part "file" is usually a PDF file, and the second part "metadata" is a json file with metadata. Here is an example of this webservice:

package com.sngular.controller;

import com.sngular.model.Metadata;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class MultipartController {

    @PostMapping(value = "/upload", consumes = {"multipart/form-data"})
    public String fileUpload(@RequestPart(value = "metadata", required = true) Metadata metadata,
                             @RequestPart(value = "file", required = true) MultipartFile file) {
        return "ok";
    }
}

this REST service works fine when I use the dependency spring-boot-starter-web, when I change it to use spring-boot-starter-webflux It give me the following error when trying to upload the files:

{
    "timestamp": "2018-05-25T20:36:03.505+0000",
    "path": "/upload",
    "status": 415,
    "error": "Unsupported Media Type",
    "message": "Content type 'application/pdf' not supported"
}

this example can be found on the following repository:

https://github.com/fjavierjimenez/springboot-multipart-test

And the postman request Im executing..
multipart

Any thoughts on why this gives me the error Content type 'application/pdf' not supported or how to solve this?

Metadata

Metadata

Assignees

Labels

for: stackoverflowA question that's better suited to stackoverflow.com

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions