Issue Details (XML | Word | Printable)

Key: JERSEY-2075
Type: Bug Bug
Status: Resolved Resolved
Resolution: Cannot Reproduce
Priority: Major Major
Assignee: Michal Gajdos
Reporter: dynaheir
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
jersey

Boundary never generated multipart/formdata

Created: 02/Sep/13 05:49 AM   Updated: 04/Dec/13 07:43 PM   Resolved: 04/Dec/13 07:43 PM
Component/s: media
Affects Version/s: 2.2
Fix Version/s: 2.5

Time Tracking:
Original Estimate: 30 minutes
Original Estimate - 30 minutes
Remaining Estimate: 0 minutes
Remaining Estimate - 0 minutes
Time Spent: 1 minute
Time Spent - 1 minute Time Not Required

Tags: jersey jersey-client multipart/form-data
Participants: dynaheir and Michal Gajdos


 Description  « Hide

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())));



Michal Gajdos added a comment - 04/Dec/13 07:42 PM

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).


Michal Gajdos added a comment - 04/Dec/13 07:43 PM

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