Annotation Type FormDataParam
-
@Target({PARAMETER,METHOD,FIELD}) @Retention(RUNTIME) @ParamQualifier public @interface FormDataParam
Binds the named body part(s) of a "multipart/form-data" request entity body to a resource method parameter. TheFormParamannotation in conjunction with the media type "application/x-www-form-urlencoded" is inefficient for sending and consuming large quantities of binary data or text containing non-ASCII characters. This annotation in conjunction with the media type "multipart/form-data" should be used for submitting and consuming forms that contain files, non-ASCII data, and binary data. The typeTof the annotated parameter must be one of the following:FormDataBodyPart. The value of the parameter will be the first named body part, otherwise null if such a named body part is not present.- A
ListorCollectionofFormDataBodyPart. The value of the parameter will one or more named body parts with the same name, otherwise null if such a named body part is not present. FormDataContentDisposition. The value of the parameter will be the content disposition of the first named body part, otherwise null if such a named body part is not present.- A
ListorCollectionofFormDataContentDisposition. The value of the parameter will one or more content dispositions of the named body parts with the same name, otherwise null if such a named body part is not present. - A type for which a message body reader is available given the media type
of the first named body part. The value of the parameter will be the
result of reading using the message body reader given the type
T, the media type of the named part, and the bytes of the named body part as input.If there is no named part present and there is a default value present as declared by
DefaultValuethen the media type will be set to "text/plain". The value of the parameter will be the result of reading using the message body reader given the typeT, the media type "text/plain", and the UTF-8 encoded bytes of the default value as input.If there is no message body reader available and the type
Tconforms to a type specified byFormParamthen processing is performed as specified byFormParam, where the values of the form parameter areStringinstances produced by reading the bytes of the named body parts utilizing a message body reader for theStringtype and the media type "text/plain".If there is no named part present then processing is performed as specified by
FormParam.
Where the server consumes a "multipart/form-data" request entity body that contains one optional named body part "enabled" and two required named body parts "data" and "file". The optional part "enabled" is processed as a@POST @Consumes(MediaType.MULTIPART_FORM_DATA_TYPE) public String postForm( @DefaultValue("true") @FormDataParam("enabled") boolean enabled, @FormDataParam("data") FileData bean, @FormDataParam("file") InputStream file, @FormDataParam("file") FormDataContentDisposition fileDisposition) { ... }booleanvalue, if the part is absent then the value will betrue. The part "data" is processed as a JAXB bean and contains some meta-data about the following part. The part "file" is a file that is uploaded, this is processed as anInputStream. Additional information about the file from the "Content-Disposition" header can be accessed by the parameterfileDisposition. Note that, whilst the annotation target permits use on fields and methods, this annotation is only required to be supported on resource method parameters.- Author:
- Craig McClanahan, Paul Sandoz, Michal Gajdos
- See Also:
FormDataMultiPart,FormDataBodyPart,FormDataContentDisposition,DefaultValue,FormParam
-
-
Element Detail
-
value
String value
Defines the control name of a "multipart/form-data" body part whose content will be used to initialize the value of the annotated method argument.- Returns:
- the control name of a "multipart/form-data" body part.
-
-