Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Publisher<Part> in MultipartBodyBuilder#asyncPart #22876

Closed
p3ndu opened this issue May 3, 2019 · 1 comment
Closed

Support Publisher<Part> in MultipartBodyBuilder#asyncPart #22876

p3ndu opened this issue May 3, 2019 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@p3ndu
Copy link

p3ndu commented May 3, 2019

Hi,

While trying a similar solution like in issue #21142

@PostMapping(path = "/upload/identifiers")
public Mono<FileRef> saveWithIdentifier(@RequestPart("file") Mono<FilePart> file) {

    MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder();
    bodyBuilder.asyncPart("file", file, FilePart.class);

    return WebClient.create(SOME_URL).put()
            .uri(FILE_UPLOAD_URI)
            .syncBody(bodyBuilder.build())
            .retrieve()
            .bodyToMono(FileRef.class);

throws an exception:

org.springframework.core.codec.CodecException: No suitable writer found for part: file

Is this an issue, incomplete documentation or am I just not using it right?

Regards,
Alex

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 3, 2019
@rstoyanchev
Copy link
Contributor

The asyncPart method is expecting actual content, i.e. file.content(). I'll update it to unwrap the part content automatically. In the mean time use:

bodyBuilder.asyncPart("file", file.content(), DataBuffer.class);

@rstoyanchev rstoyanchev self-assigned this May 8, 2019
@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement labels May 8, 2019
@rstoyanchev rstoyanchev added this to the 5.2 M2 milestone May 8, 2019
@rstoyanchev rstoyanchev changed the title CodecException: No suitable writer found for part: file Support Publisher<Part> in MultipartBodyBuilder#asyncPart May 8, 2019
@rstoyanchev rstoyanchev removed the status: waiting-for-triage An issue we've not yet triaged or decided on label May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants