Class BlobWrapper

java.lang.Object
org.nuxeo.ecm.core.api.impl.blob.BlobWrapper
All Implemented Interfaces:
Serializable, Blob

public class BlobWrapper extends Object implements Blob, Serializable
Wraps an existing Blob to allow setting a different filename.
Since:
5.9.2
See Also:
  • Field Details

    • blob

      protected final Blob blob
    • filename

      protected String filename
  • Constructor Details

    • BlobWrapper

      public BlobWrapper(Blob blob)
  • Method Details

    • getFilename

      public String getFilename()
      Specified by:
      getFilename in interface Blob
    • setFilename

      public void setFilename(String filename)
      Specified by:
      setFilename in interface Blob
    • getMimeType

      public String getMimeType()
      Specified by:
      getMimeType in interface Blob
    • getEncoding

      public String getEncoding()
      Specified by:
      getEncoding in interface Blob
    • getDigestAlgorithm

      public String getDigestAlgorithm()
      Specified by:
      getDigestAlgorithm in interface Blob
    • getDigest

      public String getDigest()
      Specified by:
      getDigest in interface Blob
    • setMimeType

      public void setMimeType(String mimeType)
      Specified by:
      setMimeType in interface Blob
    • setEncoding

      public void setEncoding(String encoding)
      Specified by:
      setEncoding in interface Blob
    • setDigestAlgorithm

      public void setDigestAlgorithm(String digestAlgorithm)
      Specified by:
      setDigestAlgorithm in interface Blob
    • setDigest

      public void setDigest(String digest)
      Specified by:
      setDigest in interface Blob
    • getStream

      public InputStream getStream() throws IOException
      Description copied from interface: Blob
      Gets an InputStream for the data of this blob.

      The contract of Blob is that this method can be called several times and will correctly return a new InputStream each time. In other words, several reads of the Blob can be done.

      Like all InputStream, the result must be closed when done with it to avoid resource leaks.

      Specified by:
      getStream in interface Blob
      Returns:
      the stream
      Throws:
      IOException
    • getLength

      public long getLength()
      Description copied from interface: Blob
      Gets the data length in bytes if known.
      Specified by:
      getLength in interface Blob
      Returns:
      the data length or -1 if not known
    • getByteArray

      public byte[] getByteArray() throws IOException
      Specified by:
      getByteArray in interface Blob
      Throws:
      IOException
    • getString

      public String getString() throws IOException
      Specified by:
      getString in interface Blob
      Throws:
      IOException
    • transferTo

      public void transferTo(OutputStream out) throws IOException
      Specified by:
      transferTo in interface Blob
      Throws:
      IOException
    • transferTo

      public void transferTo(File file) throws IOException
      Specified by:
      transferTo in interface Blob
      Throws:
      IOException
    • getFile

      public File getFile()
      Description copied from interface: Blob
      If this blob is backed by an actual file, returns it.

      The returned file may be short-lived (temporary), so should be used immediately.

      Specified by:
      getFile in interface Blob
      Returns:
      a file, or null if the blob is not backed by a file
    • getCloseableFile

      public CloseableFile getCloseableFile() throws IOException
      Description copied from interface: Blob
      Gets a CloseableFile backing this blob, which must be closed when done by the caller.

      The returned file may be the original file, a temporary file, or a symbolic link.

      Specified by:
      getCloseableFile in interface Blob
      Returns:
      a closeable file, to be closed when done
      Throws:
      IOException
    • getCloseableFile

      public CloseableFile getCloseableFile(String ext) throws IOException
      Description copied from interface: Blob
      Gets a CloseableFile backing this blob, which must be closed when done by the caller.

      The returned file may be the original file, a temporary file, or a symbolic link.

      Specified by:
      getCloseableFile in interface Blob
      Parameters:
      ext - the required extension for the file, or null if it doesn't matter
      Returns:
      a closeable file, to be closed when done
      Throws:
      IOException