Question

Have a need to provide file upload feature using Jax-Rs Jersey-1.x resource. I want to know if its better to create the method with "File" as parameter or "InputStream"?

Resource will accept application/octet-stream content-type and not tied to form-data. it will need to work with small to huge size (upto gig) files.

want to know if using InputStream as method parameter over File (or vice versa) has any advantage? (ex: memory optimization) Jersey Runtime server is Tomcat

Was it helpful?

Solution

This answer is extremely implementation specific, but from what I remember with both Jersey and CXF, File would make a copy, but is not subject to the vagaries of the HTTP connection, whereas InputStream does NOT make a copy, but could not be passed around to be consumed by other processes (because it's tied to the InputStream of the HTTP Request...)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top