- java.lang.Object
-
- com.github.elopteryx.upload.rs.UploadReader
-
- All Implemented Interfaces:
com.github.elopteryx.upload.OnPartBegin,com.github.elopteryx.upload.OnPartEnd,MessageBodyReader<Object>
@Consumes("multipart/form-data") public class UploadReader extends Object implements MessageBodyReader<Object>, com.github.elopteryx.upload.OnPartBegin, com.github.elopteryx.upload.OnPartEnd
This class is a message body reader for multipart requests. It works like the blocking upload parser. It provides a default configuration which creates temporary files to store uploaded file data and stores each normal form field in aByteArrayOutputStreaminstance. Other readers can extend this and implement the callback interfaces, which are the part begin and end callbacks. You must manually register this or its subclass to be used by the Jax-Rs runtime.The reader does not support the request callback, because that code can go into the controller method instead and the error callback, because there are exception mappers for that.
The reader can inject the following parameters:
MultiPartPartwith a validUploadParamannotationCollectionofPartinstancesListofPartinstances
Other parameters are not supported by the reader.
-
-
Constructor Summary
Constructors Constructor Description UploadReader()Public constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)com.github.elopteryx.upload.PartOutputonPartBegin(com.github.elopteryx.upload.UploadContext context, ByteBuffer buffer)voidonPartEnd(com.github.elopteryx.upload.UploadContext context)ObjectreadFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,String> httpHeaders, InputStream entityStream)
-
-
-
Method Detail
-
isReadable
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)
- Specified by:
isReadablein interfaceMessageBodyReader<Object>
-
readFrom
public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException
- Specified by:
readFromin interfaceMessageBodyReader<Object>- Throws:
IOExceptionWebApplicationException
-
onPartBegin
public com.github.elopteryx.upload.PartOutput onPartBegin(com.github.elopteryx.upload.UploadContext context, ByteBuffer buffer) throws IOException- Specified by:
onPartBeginin interfacecom.github.elopteryx.upload.OnPartBegin- Throws:
IOException
-
onPartEnd
public void onPartEnd(com.github.elopteryx.upload.UploadContext context) throws IOException- Specified by:
onPartEndin interfacecom.github.elopteryx.upload.OnPartEnd- Throws:
IOException
-
-