Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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

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

    public class StreamDataBodyPart

extends FormDataBodyPart

Represents an `InputStream` based file submission as a part of the multipart/form-data.

It sets the `InputStream` as a body part with the default `MediaType.APPLICATION_OCTET_STREAM_TYPE` (if not specified by the user).
Note that the MIME type of the entity cannot be automatically predicted as in case of `FileDataBodyPart`.

The filename of the attachment is set by the user or defaults to the part's name.

Author:
  PedroKowalski (pallipp@gmail.com)
See Also:
  `FileDataBodyPart`

Field Summary

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

Constructor Summary
`StreamDataBodyPart()` Default constructor which forces user to manually set the required (`name` and `streamEntity`) properties.
`StreamDataBodyPart(java.lang.String name, java.io.InputStream streamEntity)` Convenience constructor which assumes the defaults for: `filename` (part's name) and `mediaType` ( `MediaType.APPLICATION_OCTET_STREAM_TYPE`).
`StreamDataBodyPart(java.lang.String name, java.io.InputStream streamEntity, java.lang.String filename)` Convenience constructor which assumes the defaults for the `mediaType` (`MediaType.APPLICATION_OCTET_STREAM_TYPE`).
`StreamDataBodyPart(java.lang.String name, java.io.InputStream streamEntity, java.lang.String filename, MediaType mediaType)` All-arguments constructor with all requested parameters set by the caller.

Method Summary
`protected FormDataContentDisposition` | `buildContentDisposition()` Builds the body part content-disposition header which the specified filename (or the default one if unspecified).
`protected static MediaType` | `getDefaultMediaType()` Gets the default `MediaType` to be used if the user didn't specify any.
`java.lang.String` | `getFilename()` Gets the filename value which is to be used in the content-disposition header of this body part entity.
`java.io.InputStream` | `getStreamEntity()` Gets the underlying stream entity which will form the body part entity.
`void` | `setEntity(java.lang.Object entity)` This operation is not supported from this implementation.
`void` | `setFilename(java.lang.String filename)` Sets the body part entity filename value to be used in the content-disposition header.
`void` | `setStreamEntity(java.io.InputStream streamEntity)` Allows to explicitly set the body part entity.
`void` | `setStreamEntity(java.io.InputStream streamEntity, MediaType mediaType)` Allows to explicitly set the value and the MIME type of the body part entity.
`void` | `setValue(MediaType mediaType, java.lang.Object value)` This operation is not supported from this implementation.
`void` | `setValue(java.lang.String 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`

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

### StreamDataBodyPart

    public StreamDataBodyPart()

  Default constructor which forces user to manually set the required (`name` and `streamEntity`) properties.

  `setFilename(String)` can be used to set user-specified attachment filename instead of the default one.

  See Also:
    `FormDataBodyPart.setName(String)`, `setStreamEntity(InputStream, MediaType)`

### StreamDataBodyPart

    public StreamDataBodyPart(java.lang.String name,
                              java.io.InputStream streamEntity)

  Convenience constructor which assumes the defaults for: `filename` (part's name) and `mediaType` ( `MediaType.APPLICATION_OCTET_STREAM_TYPE`).

  It builds the requested body part and makes the part ready for submission.

  Parameters:
    `name` - name of the form-data field
    `streamEntity` - entity to be set as a body part

### StreamDataBodyPart

    public StreamDataBodyPart(java.lang.String name,
                              java.io.InputStream streamEntity,
                              java.lang.String filename)

  Convenience constructor which assumes the defaults for the `mediaType` (`MediaType.APPLICATION_OCTET_STREAM_TYPE`).

  It builds the requested body part and makes the part ready for submission.

  Parameters:
    `name` - name of the form-data field
    `streamEntity` - entity to be set as a body part
    `filename` - filename of the sent attachment (to be set as a part of `content-disposition`)

### StreamDataBodyPart

    public StreamDataBodyPart(java.lang.String name,
                              java.io.InputStream streamEntity,
                              java.lang.String filename,
                              MediaType mediaType)

  All-arguments constructor with all requested parameters set by the caller.

  It builds the requested body part and makes the part ready for submission.

  Parameters:
    `name` - name of the form-data field
    `streamEntity` - entity to be set as a body part
    `filename` - filename of the sent attachment (to be set as a part of `content-disposition`)
    `mediaType` - MIME type of the `streamEntity` attachment
  Throws:
    `java.lang.IllegalArgumentException` - if `name` or `streamEntity` are null.

Method Detail

### setValue

    public void setValue(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` - the media type for this field value
    `value` - the field value as a Java object
  Throws:
    `java.lang.UnsupportedOperationException` - Operation not supported.
  See Also:
    `setStreamEntity(InputStream, MediaType)`

### setValue

    public void setValue(java.lang.String value)

  This operation is not supported from this implementation.

  Overrides:
    `setValue` in class `FormDataBodyPart`
  Parameters:
    `value` - the field value
  Throws:
    `java.lang.UnsupportedOperationException` - Operation not supported.
  See Also:
    `setStreamEntity(InputStream)`

### 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` - The new entity object
  Throws:
    `java.lang.UnsupportedOperationException` - Operation not supported.
  See Also:
    `setStreamEntity(InputStream, MediaType)`

### setStreamEntity

    public void setStreamEntity(java.io.InputStream streamEntity)

  Allows to explicitly set the body part entity. This method assumes the default `MediaType.APPLICATION_OCTET_STREAM` MIME type and doesn't have to be invoked if one of the non-default constructors was already called.

  Either this method or `setStreamEntity(InputStream, MediaType)` must be invoked if the default constructor was called.

  Parameters:
    `streamEntity` - entity to be set as a body part

### setStreamEntity

    public void setStreamEntity(java.io.InputStream streamEntity,
                                MediaType mediaType)

  Allows to explicitly set the value and the MIME type of the body part entity. This method doesn't have to be invoked if one of the non-default constructors was already called.

  Either this method or `setStreamEntity(InputStream)` must be invoked if the default constructor was called.

  Parameters:
    `streamEntity` - entity to be set as a body part
    `mediaType` - MIME type of the `streamEntity` attachment

### buildContentDisposition

    protected FormDataContentDisposition buildContentDisposition()

  Builds the body part content-disposition header which the specified filename (or the default one if unspecified).

  Returns:
    ready to use content-disposition header

### getDefaultMediaType

    protected static MediaType getDefaultMediaType()

  Gets the default `MediaType` to be used if the user didn't specify any.

  Returns:
    default `MediaType` for this body part entity.

### setFilename

    public void setFilename(java.lang.String filename)

  Sets the body part entity filename value to be used in the content-disposition header.

  Parameters:
    `filename` - name to be used

### getStreamEntity

    public java.io.InputStream getStreamEntity()

  Gets the underlying stream entity which will form the body part entity.

  Returns:
    underlying stream.

### getFilename

    public java.lang.String getFilename()

  Gets the filename value which is to be used in the content-disposition header of this body part entity.

  Returns:
    filename

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2013 Oracle Corporation. All Rights Reserved.