Package com.isomorphic.servlet

# Class ISCFileItem

java.lang.Object
com.isomorphic.servlet.ISCFileItem

All Implemented Interfaces:
  `org.apache.commons.fileupload2.core.FileItem<ISCFileItem>`, `org.apache.commons.fileupload2.core.FileItemHeadersProvider<ISCFileItem>`

public class ISCFileItem extends Object implements org.apache.commons.fileupload2.core.FileItem<ISCFileItem>
This class is based on the Apache Commons FileUpload FileItem class, providing uploaded file APIs for the SmartClient Server.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `byte[]`
  `get()`
  Returns the entire contents of the uploaded file as a byte array.
  `String`
  `getFileName()`
  `InputStream`
  `getInputStream()`
  Returns an InputStream for reading the uploaded file content.
  `long`
  `getSize()`

- ## Method Details

  - ### get

    public byte[] get()
    Returns the entire contents of the uploaded file as a byte array.

    Warning: For large files that exceed the disk storage threshold (configured via `fileUpload.sizeThreshold`), calling this method defeats the purpose of disk-based storage by loading the entire file into memory. For large files, use `getInputStream()` instead, which returns a stream that reads directly from the temp file without allocating a buffer for the entire file contents.

    This method is appropriate for small files or when the entire file content is genuinely needed in memory (e.g., for computing a hash of the complete content).

    Returns:
      bytes of the uploaded file
    See Also:
      - `getInputStream()`
      - `isInMemory()`

  - ### getInputStream

    public InputStream getInputStream()
    Returns an InputStream for reading the uploaded file content. This is the preferred method for accessing large file uploads because it does not require loading the entire file into memory. For files stored on disk (those exceeding the `fileUpload.sizeThreshold`), this returns a stream that reads directly from the temp file.

    This method always returns the InputStream associated with the originally uploaded file. This is not necessarily the same object as that returned by DSRequest.getUploadedFileStream(), because that method can be influenced by user code setting the value of a field in the values map to a different InputStream. Eg, if the request contains an uploaded file for a field called "myField", user code in a DMI or custom DataSource could do something like this to override the stream processed by the server:

    `InputStream newStream = someFunctionThatReturnsAnInputStream(); dsRequest.getValues().put("myField", newStream);`

    Note: Callers are responsible for closing the returned InputStream when done.

    Returns:
      InputStream for reading the uploaded file, or null if no data is available
    See Also:
      - `get()`
      - `isInMemory()`
      - `DSRequest.getUploadedFileStream(java.lang.String)`

  - ### getSize

    public long getSize()
    Returns:
      size of the uploaded file in bytes

  - ### getFileName

    public String getFileName()
    Returns:
      filename as it appears in the upload field on the client (typically includes full path to file on the user's machine)