1

I've configured the REST channel for file upload according to IBM article http://www-01.ibm.com/support/knowledgecenter/SS7K4U_7.0.0/com.ibm.websphere.web2mobile.mobile.application.services.help/docs/fileuploader_README.html?cp=SS7K4U_7.0.0%2F8-13-3 :

import org.apache.wink.common.model.multipart.BufferedInMultiPart;

@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
@Path("/upload")
public RestResult upload(BufferedInMultiPart bimp) {
    List<InPart> parts = bimp.getParts();
    // ....
}

I've added the test consumption of the stream, just to make sure the request is fully processed:

IOUtils.copy(part.getInputStream(), new NullOutputStream());

I've tested the whole with really big uploades - about 100MB. I've noticed the dramatic memory usage increase on Websphere server, much bigger that by uploading little files. I assume this is caused by the uploaded file being placed into memory after upload, and before calling my upload function.

Is it possible to configure the tool so that the big files are read into some temporary file, instead of memory?

Or is it possible to become the incoming input stream directly in the REST channnel method?

I'm using Websphere 8.5 and JAX-WS REST channel.

ᄂ ᄀ
  • 5,669
  • 6
  • 43
  • 57
Danubian Sailor
  • 1
  • 38
  • 145
  • 223

1 Answers1

2

According to Apache Wink documentation found here, it seems that BufferedInMultiPart stores complete file into memory, so try to replace BufferedInMultiPart with InMultiPart:

import org.apache.wink.common.model.multipart.InMultiPart;

@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
@Path("/upload")
public RestResult upload(InMultiPart bimp) {
    List<InPart> parts = new ArrayList<InPart>();
    while(bimp.hasNext()) {
        parts.add(bimp.next());
    }
    // ....
}
Magic Wand
  • 1,572
  • 10
  • 9
  • Yeah, I'd like to write that as comment to that IBM article, but you need IBM ID to do that :) – Danubian Sailor Sep 03 '14 at 14:51
  • @Donaudampfschifffreizeitfahrt If you want, you still can. This is free registration here - https://www.ibm.com/account/profile/us?page=reg will also allow you to participate in developerWorks forums. :-) – Gas Sep 03 '14 at 15:35