public class FileDataBodyPart extends FormDataBodyPart
FormDataBodyPart for associating
File File as a body part entity.
This class may be used to create body parts that a file attachments. Where appropriate the Content-Disposition parameters and Content-Type header will be derived from the file.
| Constructor and Description |
|---|
FileDataBodyPart()
A no-args constructor which expects its client to set the values
individually, the attributes to be set are fileEntity and name; the
media type will be predicted from the fileEntity if not set explicitly
|
FileDataBodyPart(java.lang.String name,
java.io.File fileEntity)
Constructs the body part with the provided name and file, it predicts the
MediaType of the file provided. |
FileDataBodyPart(java.lang.String name,
java.io.File fileEntity,
MediaType mediaType)
Constructs the body part with all the attributes set for its proper
function.
|
| Modifier and Type | Method and Description |
|---|---|
java.io.File |
getFileEntity()
Get the file for this body part.
|
MediaTypePredictor |
getPredictor()
Get the media type predictor.
|
protected MediaType |
predictMediaType()
Predict the media type of the current fileEntity.
|
protected MediaType |
predictMediaType(java.io.File file)
Predict the media type of the provided
File. |
void |
setEntity(java.lang.Object entity)
This operation is not supported from this implementation.
|
void |
setFileEntity(java.io.File fileEntity)
Sets the fileEntity for this
FormDataBodyPart. |
void |
setFileEntity(java.io.File fileEntity,
MediaType mediaType)
Sets the
MediaType and fileEntity for this FormDataBodyPart. |
void |
setPredictor(MediaTypePredictor predictor)
Set the media type predictor.
|
void |
setValue(MediaType mediaType,
java.lang.Object value)
This operation is not supported from this implementation.
|
getContentDisposition, getFormDataContentDisposition, getName, getValue, getValueAs, isSimple, setContentDisposition, setFormDataContentDisposition, setName, setValuecleanup, contentDisposition, entity, getEntity, getEntityAs, getHeaders, getMediaType, getParameterizedHeaders, getParent, getProviders, setMediaType, setParent, setProviders, typepublic FileDataBodyPart()
public FileDataBodyPart(java.lang.String name,
java.io.File fileEntity)
MediaType of the file provided. For the known media types client
will not need to set the media type explicitly.name - The name of body partfileEntity - The file that represents the entityMediaTypePredictor.getMediaTypeFromFile(java.io.File),
FileDataBodyPart(java.lang.String, java.io.File, javax.ws.rs.core.MediaType)public FileDataBodyPart(java.lang.String name,
java.io.File fileEntity,
MediaType mediaType)
throws java.lang.IllegalArgumentException
name - The name of body partfileEntity - The file that represents the entitymediaType - The MediaType of the body partjava.lang.IllegalArgumentException - If the fileEntity is nullpublic java.io.File getFileEntity()
public void setValue(MediaType mediaType, java.lang.Object value) throws java.lang.UnsupportedOperationException
setValue in class FormDataBodyPartmediaType - value - java.lang.UnsupportedOperationException - Operation not supported.setFileEntity(java.io.File, javax.ws.rs.core.MediaType)public void setEntity(java.lang.Object entity)
throws java.lang.UnsupportedOperationException
setEntity in class BodyPartentity - java.lang.UnsupportedOperationException - Operation not supported.setFileEntity(java.io.File)public void setFileEntity(java.io.File fileEntity)
FormDataBodyPart.fileEntity - The entity of this FormDataBodyPart.public void setFileEntity(java.io.File fileEntity,
MediaType mediaType)
MediaType and fileEntity for this FormDataBodyPart.fileEntity - The entity of this body partmediaType - the media type.protected MediaType predictMediaType()
MediaTypeprotected MediaType predictMediaType(java.io.File file)
File.file - the file from which the media type is predicted.MediaTypepublic MediaTypePredictor getPredictor()
public void setPredictor(MediaTypePredictor predictor)
predictor - the media type predictor.Copyright © 2016 Oracle Corporation. All Rights Reserved.