## com.sun.jersey.multipart.file
Class FileDataBodyPart

    java.lang.Object
      com.sun.jersey.multipart.BodyPart
          com.sun.jersey.multipart.FormDataBodyPart
              com.sun.jersey.multipart.file.FileDataBodyPart

    public class FileDataBodyPart

extends FormDataBodyPart

An extension of `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.

Author:
  imran@smartitengineering.com, Paul.Sandoz@Sun.Com

Field Summary

Fields inherited from class com.sun.jersey.multipart.BodyPart
`cd`

Constructor Summary
`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, javax.ws.rs.core.MediaType mediaType)` Constructs the body part with all the attributes set for its proper function.

Method Summary
`java.io.File` | `getFileEntity()` Get the file for this body part.
`MediaTypePredictor` | `getPredictor()` Get the media type predictor.
`protected javax.ws.rs.core.MediaType` | `predictMediaType()` Predict the media type of the current fileEntity.
`protected javax.ws.rs.core.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, javax.ws.rs.core.MediaType mediaType)` Sets the `MediaType` and fileEntity for this `FormDataBodyPart`.
`void` | `setPredictor(MediaTypePredictor predictor)` Set the media type predictor.
`void` | `setValue(javax.ws.rs.core.MediaType mediaType, java.lang.Object value)` This operation is not supported from this implementation.

Methods inherited from class com.sun.jersey.multipart.FormDataBodyPart
`getContentDisposition, getFormDataContentDisposition, getName, getValue, getValueAs, isSimple, setContentDisposition, setFormDataContentDisposition, setName, setValue`

Methods inherited from class com.sun.jersey.multipart.BodyPart
`cleanup, contentDisposition, entity, getEntity, getEntityAs, getHeaders, getMediaType, getParameterizedHeaders, getParent, getProviders, setMediaType, setParent, setProviders, type`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### FileDataBodyPart

    public 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

    public 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. For the known media types client will not need to set the media type explicitly.

  Parameters:
    `name` - The name of body part
    `fileEntity` - The file that represents the entity
  See Also:
    `MediaTypePredictor.getMediaTypeFromFile(java.io.File)`, `FileDataBodyPart(java.lang.String, java.io.File, javax.ws.rs.core.MediaType)`

### FileDataBodyPart

    public FileDataBodyPart(java.lang.String name,
                            java.io.File fileEntity,
                            javax.ws.rs.core.MediaType mediaType)
                     throws java.lang.IllegalArgumentException

  Constructs the body part with all the attributes set for its proper function. If this constructor is used to construct the body part then it is not required to set any other attributes for proper behavior.

  Parameters:
    `name` - The name of body part
    `fileEntity` - The file that represents the entity
    `mediaType` - The `MediaType` of the body part
  Throws:
    `java.lang.IllegalArgumentException` - If the fileEntity is null

Method Detail

### getFileEntity

    public java.io.File getFileEntity()

  Get the file for this body part.

  Returns:
    File entity for this body part

### setValue

    public void setValue(javax.ws.rs.core.MediaType mediaType,
                         java.lang.Object value)
                  throws java.lang.UnsupportedOperationException

  This operation is not supported from this implementation.

  Overrides:
    `setValue` in class `FormDataBodyPart`
  Parameters:
    `mediaType` -
    `value` -
  Throws:
    `java.lang.UnsupportedOperationException` - Operation not supported.
  See Also:
    `setFileEntity(java.io.File, javax.ws.rs.core.MediaType)`

### setEntity

    public void setEntity(java.lang.Object entity)
                   throws java.lang.UnsupportedOperationException

  This operation is not supported from this implementation.

  Overrides:
    `setEntity` in class `BodyPart`
  Parameters:
    `entity` -
  Throws:
    `java.lang.UnsupportedOperationException` - Operation not supported.
  See Also:
    `setFileEntity(java.io.File)`

### setFileEntity

    public void setFileEntity(java.io.File fileEntity)

  Sets the fileEntity for this `FormDataBodyPart`.

  Parameters:
    `fileEntity` - The entity of this `FormDataBodyPart`.

### setFileEntity

    public void setFileEntity(java.io.File fileEntity,
                              javax.ws.rs.core.MediaType mediaType)

  Sets the `MediaType` and fileEntity for this `FormDataBodyPart`.

  Parameters:
    `fileEntity` - The entity of this body part
    `mediaType` - the media type.

### predictMediaType

    protected javax.ws.rs.core.MediaType predictMediaType()

  Predict the media type of the current fileEntity.

  Returns:
    Predicted `MediaType`

### predictMediaType

    protected javax.ws.rs.core.MediaType predictMediaType(java.io.File file)

  Predict the media type of the provided `File`.

  Parameters:
    `file` - the file from which the media type is predicted.
  Returns:
    Predicted `MediaType`

### getPredictor

    public MediaTypePredictor getPredictor()

  Get the media type predictor.

  Returns:
    the media type predictor.

### setPredictor

    public void setPredictor(MediaTypePredictor predictor)

  Set the media type predictor.

  Parameters:
    `predictor` - the media type predictor.

Copyright © 2017 Oracle Corporation. All Rights Reserved.