Skip to content
This repository was archived by the owner on Oct 1, 2018. It is now read-only.
This repository was archived by the owner on Oct 1, 2018. It is now read-only.

java.lang.IllegalStateException in BodyPartEntity getInputStream() using RESTful POST request #14

@KrithikaKR17

Description

@KrithikaKR17

Hello,

I am trying to download multiple attachments in REST mode using FormDataMultiPart (app1 to app2). I am facing an exception when I try to extract the input stream from BodyPartEntity on the REST based application side.
At first glance, it looks like the input stream in the MIMEParser of BodyPartEntity seems to be already parsed. Surprisingly this is working fine in the other way around (app2 to app1). I am using mimepull version 1.9.3.

Kindly help me in resolving this issue.

Stacktrace is:

java.lang.IllegalStateException: No such MIME Part: Part=0:binary
at org.jvnet.mimepull.DataHead.read(DataHead.java:145)
at org.jvnet.mimepull.MIMEPart.read(MIMEPart.java:94)
at org.glassfish.jersey.media.multipart.BodyPartEntity.getInputStream(BodyPartEntity.java:80)

The code to construct the inputStream and attach it to FormDataMultiPart:

for(int i = 0; i < attachments.length; i++) {
InputStream inputStream = new FileInputStream(new File("sample.xml"));
formDataMultiPart.field("files", inputStream, MediaType.TEXT_XML_TYPE);
}

The code to get the inputStream is:

List bodyParts = attachments.getFields("files");
for(int i = 1; i < bodyParts.size(); i++) {
BodyPartEntity bodyPartEntity = (BodyPartEntity) bodyParts.get(i).getEntity();
InputStream is = bodyPartEntity.getInputStream();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions