I'm trying to upload a file from a client through a portal to a rest service
that will accept the file. The client has no access to the server hosting
the file upload service, so I have to go through a portlet controller to
upload the file. Where I'm having trouble is avoiding storing the file in
temporary storage or in memory as the file can be rather large. So I'm
trying to send the inputstream directly from the first multipart request to
the service. Is this possible? Is this a bad idea?
I've tried a number of things but it seems that when I send a stream the
content disposition doesn't get set correctly and the service sees the file
as form field and not a file upload. Here's some code examples:
FormDataMultiPart multipart = new FormDataMultiPart();
multipart.bodyPart(new BodyPart(fileItem.getFileInputStream(),
MediaType.APPLOCATION_OCTET_STREAM_TYPE));
client.resource(URI).type(MediaType.MULTIPART_FORM_DATA).post(String.class,
multipart);
If I do something like that the content disposition doesn't get formed
correctly, and the service has no idea what my request is. If I try to
manually set the content disposition I still have no luck and the stream is
seen as a form field and not a file.
I've also tried using a field instead of a body part, but that doesn't work
either. Is it best to just write the file to a temporary location on the
portal and then using the FileDataBodyPart?
Thanks,
David
--
View this message in context: http://jersey.576304.n2.nabble.com/jersey-multipart-issues-tp5722709p5722709.html
Sent from the Jersey mailing list archive at Nabble.com.