How do you build a servlet proxy that accepts file uploads?

I’m trying to build a simple servlet proxy which takes a file input and uploads it to TRIRIGA. When I test it with the correct parameters, I receive this WebSphere error:

SRVE8020E: Servlet does not accept multipart requests

I plan on using the upload method. Currently, I’m stuck on getting the request to include the data. Here is a snippet of my code taking the parameters:

Part filePart = request.getPart("file");
Long recordId = Long.parseLong(request.getParameter("RecordID"));
String fieldName = request.getParameter("fieldName");
InputStream fileContent = filePart.getInputStream();

The upload to TRIRIGA is easy, but getting these parameters from the request is where I’m experiencing the issue… I’ve created a few classes before that are called using GET with parameters in the URL and everything worked fine. I’m just not sure if it supports POST with the multipart request… I will be triggering this from a UX application. Since it doesn’t support file/image uploads, I’m looking into building a custom solution using servlet proxies.

For that use case, another option in lieu of a servlet proxy is posting the file with an OSLC API. I know there are others that have done this. The following pull request on the vaadin-upload component was actually done to help facilitate this: Upload Mode with option RAW added. So essentially, it’s a direct post to the REST endpoint rather than a form post. Also, it’s worth mentioning that we do tentatively plan to add a TRIRIGA component for file upload in our next release, but hopefully this helps in the meantime.

Continue reading


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.