jersey
  1. jersey
  2. JERSEY-2075

Boundary never generated multipart/formdata

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.2
    • Fix Version/s: 2.5
    • Component/s: media
    • Labels:
      None

      Description

      FormDataMultiPart is never generating a boundary for me which is required for the below snippet form your user guide.

      The below snippet from the user guide is incorrect and will not compile...
      .bodyPart returns a MultiPart and would need to be cast back to a FormDataMultiPart

      Jersey2.2
      http://jersey.java.net/documentation/latest/user-guide.html

      final FileDataBodyPart filePart = new FileDataBodyPart("my_pom", new File("pom.xml"));
      final FormDataMultiPart multipart = new FormDataMultiPart()
      .field("foo", "bar")
      .bodyPart(filePart);

      final WebTarget target = // Create WebTarget.
      final Response response = target.request()
      .post(Entity.entity(multipart, multipart.getMediaType()));

      To work around this issue I had to take control of the media type
      MultiPart form = new FormDataMultiPart()
      .bodyPart(new FormDataBodyPart("asset", asset, MediaType.APPLICATION_XML_TYPE))
      .bodyPart(new StreamDataBodyPart("file", fileStream))
      .type(new MediaType("multipart", "form-data",
      Collections.singletonMap(Boundary.BOUNDARY_PARAMETER, Boundary.createBoundary())));

        Activity

        Hide
        Michal Gajdos added a comment -

        Cannot reproduce with default client. If ApacheConnector is used then this issue should be solved with JERSEY-2123. If the issue persist feel free to reopen (please, provide stacktrace).

        Show
        Michal Gajdos added a comment - Cannot reproduce with default client. If ApacheConnector is used then this issue should be solved with JERSEY-2123 . If the issue persist feel free to reopen (please, provide stacktrace).
        Hide
        Michal Gajdos added a comment -

        Closing as cannot reproduce. Test-case for the default client will be provided with a fix for JERSEY-2123.

        Show
        Michal Gajdos added a comment - Closing as cannot reproduce. Test-case for the default client will be provided with a fix for JERSEY-2123 .

          People

          • Assignee:
            Michal Gajdos
            Reporter:
            dynaheir
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 30 minutes
              30m
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 1 minute Time Not Required
              1m