Skip to content

Content-Disposition for multipart formdata is not correctly set when using Mono<DataBuffer> source #22616

Closed

Description

@stdreyer

I tried for hours to upload data via multipart post request with WebClient. As async part I use a mono from a databuffer:

    final MultipartBodyBuilder builder = new MultipartBodyBuilder();
    builder.asyncPart("file", Mono.just(someDataBuffer), DataBuffer.class);
    MultiValueMap<String, ?> data = builder.build();
    
    return webClient
        .post()
        .uri("http://myurl/upload")
        .body(BodyInserters.fromMultipartData(data))
        .retrieve()
        .bodyToMono(String.class);

That always failed because there is not filename known in the generated content disposition header. A good way to solve this would be to add a filename parameter to the asyncPart builder.

Activity

  1. added
    status: waiting-for-triage
    on Mar 19, 2019
  2. rstoyanchev commented on Apr 12, 2019

    @rstoyanchev
    Contributor

    When getting a link to a source code line, please don't simply point to master because those lines change and sometimes it can be hard to notice. Hit 'y` to get a link for a fixed point in time.

  3. rstoyanchev commented on Apr 12, 2019

    @rstoyanchev
    Contributor

    Currently MultipartBuilderBuilder accepts a part name but the underlying HttpHeaders#setContentDispositionFormData also accepts an optional filename. I think the suggestion makes sense. We could add a couple of extra methods in MultipartBodyBuilder that also accept a filename.

  4. added
    in: web
    type: enhancement
    and removed
    status: waiting-for-triage
    on Apr 12, 2019
  5. added this to the 5.x Backlog milestone on Apr 12, 2019
  6. added
    status: ideal-for-contribution
    on Apr 12, 2019
  7. koziolk commented on Apr 25, 2019

    @koziolk

    @rstoyanchev If I got it correctly it's about adding new builder methods to MultipartBuilderBuilder by extending MultipartBuilderBuilder#part and MultipartBuilderBuilder#asynPart with additional filename parameter and then passing it to HttpHeaders#setContentDispositionFormData?

  8. koziolk commented on Apr 28, 2019

    @koziolk

    @rstoyanchev @stdreyer I'm interested to work on it.

  9. rstoyanchev commented on Apr 29, 2019

    @rstoyanchev
    Contributor

    @koziolk that's the idea, yes.

  10. ielatif commented on May 7, 2019

    @ielatif
    Contributor

    @koziolk did you get a chance to work on this? If not, I can pick it up if you don't mind

  11. koziolk commented on May 7, 2019

    @koziolk

    @ielatif Yes, I did. I'm going to submit a pull request Today.

  12. added a commit that references this issue on May 7, 2019
    bbdc781
  13. koziolk commented on May 7, 2019

    @koziolk

    @rstoyanchev @stdreyer I've added a filename to MultipartBuilderBuilder methods (regular and async). Take a look at my PR. Thanks.

  14. added 2 commits that reference this issue on May 7, 2019
    e89c464
    93c5721
  15. rstoyanchev commented on May 8, 2019

    @rstoyanchev
    Contributor

    Superseded by #22921.

  16. removed this from the 5.x Backlog milestone on May 8, 2019
  17. added
    status: superseded
    and removed
    status: ideal-for-contribution
    on May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webstatus: supersededtype: enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions