Hello,
i have the following Problem:
I get a deployment from a software to my Jersey REST WebService that should receive a xml-File.
If I receive it with:
<code>
@POST
@Path(“/deployment”)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public String deploy(@FormDataParam(“upload”) final String upload) {…}
</code>
I get the complete Post (written below) in one String (including the byte withe the fileData. The problem is, that I don´t get the fileData extracted out of that String in a “clean” way.
If I try to receive the POST with:
<code>
@POST
@Path(“/deployment”)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public String deploy(@FormDataParam(“upload”) final <b>FormDataMultiPart </b>upload) {…}
</code>
I get an Error “…isn´t compatible with the MIME media type…”.
Addind the mimepull.jar also didn´t solve the problem.
As I found out it looks like a standard FileUpload POST that should be received with FormDataMultiPart and then the file could be extracted as a stream for example. But that doesn´t run in my case. What can I do to get my file saved on the server?
The POST received from my Service looks like:
"
–boundary
Content-Disposition: form-data; name=“success”
success
–boundary
Content-Disposition: form-data; name=“failure”
failure
–boundary
Content-Disposition: form-data; name=“deployment”; filename=“filename”);
…and then the fileData:
<code>
while (bytesRead > 0) {
dos.write(buffer, 0, bufferSize);
bytesAvailable = fileInputStream.available();
bufferSize = Math.min(bytesAvailable, maxBufferSize);
bytesRead = fileInputStream.read(buffer, 0, bufferSize);
}
</code>
–boundary–
"
Thanks for your help,
Pascal