Package org.nuxeo.ecm.core.api.impl.blob
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 existingBlobto allow setting a different filename.- Since:
- 5.9.2
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BlobWrapper(Blob blob)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getByteArray()CloseableFilegetCloseableFile()Gets aCloseableFilebacking this blob, which must be closed when done by the caller.CloseableFilegetCloseableFile(String ext)Gets aCloseableFilebacking this blob, which must be closed when done by the caller.StringgetDigest()StringgetDigestAlgorithm()StringgetEncoding()FilegetFile()If this blob is backed by an actual file, returns it.StringgetFilename()longgetLength()Gets the data length in bytes if known.StringgetMimeType()InputStreamgetStream()Gets anInputStreamfor the data of this blob.StringgetString()voidsetDigest(String digest)voidsetDigestAlgorithm(String digestAlgorithm)voidsetEncoding(String encoding)voidsetFilename(String filename)voidsetMimeType(String mimeType)voidtransferTo(File file)voidtransferTo(OutputStream out)
-
-
-
Constructor Detail
-
BlobWrapper
public BlobWrapper(Blob blob)
-
-
Method Detail
-
getFilename
public String getFilename()
- Specified by:
getFilenamein interfaceBlob
-
setFilename
public void setFilename(String filename)
- Specified by:
setFilenamein interfaceBlob
-
getMimeType
public String getMimeType()
- Specified by:
getMimeTypein interfaceBlob
-
getEncoding
public String getEncoding()
- Specified by:
getEncodingin interfaceBlob
-
getDigestAlgorithm
public String getDigestAlgorithm()
- Specified by:
getDigestAlgorithmin interfaceBlob
-
setMimeType
public void setMimeType(String mimeType)
- Specified by:
setMimeTypein interfaceBlob
-
setEncoding
public void setEncoding(String encoding)
- Specified by:
setEncodingin interfaceBlob
-
setDigestAlgorithm
public void setDigestAlgorithm(String digestAlgorithm)
- Specified by:
setDigestAlgorithmin interfaceBlob
-
getStream
public InputStream getStream() throws IOException
Description copied from interface:BlobGets anInputStreamfor the data of this blob.The contract of
Blobis that this method can be called several times and will correctly return a newInputStreameach time. In other words, several reads of theBlobcan be done.Like all
InputStream, the result must be closed when done with it to avoid resource leaks.- Specified by:
getStreamin interfaceBlob- Returns:
- the stream
- Throws:
IOException
-
getLength
public long getLength()
Description copied from interface:BlobGets the data length in bytes if known.
-
getByteArray
public byte[] getByteArray() throws IOException- Specified by:
getByteArrayin interfaceBlob- Throws:
IOException
-
getString
public String getString() throws IOException
- Specified by:
getStringin interfaceBlob- Throws:
IOException
-
transferTo
public void transferTo(OutputStream out) throws IOException
- Specified by:
transferToin interfaceBlob- Throws:
IOException
-
transferTo
public void transferTo(File file) throws IOException
- Specified by:
transferToin interfaceBlob- Throws:
IOException
-
getFile
public File getFile()
Description copied from interface:BlobIf this blob is backed by an actual file, returns it.The returned file may be short-lived (temporary), so should be used immediately.
-
getCloseableFile
public CloseableFile getCloseableFile() throws IOException
Description copied from interface:BlobGets aCloseableFilebacking 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:
getCloseableFilein interfaceBlob- Returns:
- a closeable file, to be closed when done
- Throws:
IOException
-
getCloseableFile
public CloseableFile getCloseableFile(String ext) throws IOException
Description copied from interface:BlobGets aCloseableFilebacking 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:
getCloseableFilein interfaceBlob- Parameters:
ext- the required extension for the file, ornullif it doesn't matter- Returns:
- a closeable file, to be closed when done
- Throws:
IOException
-
-