Package org.nuxeo.ecm.core.api
Interface Blob
-
- All Known Subinterfaces:
ManagedBlob
- All Known Implementing Classes:
AbstractBlob
,AsyncBlob
,BinaryBlob
,BlobWrapper
,ByteArrayBlob
,FileBlob
,JSONBlob
,SimpleManagedBlob
,StringBlob
,URLBlob
,ZipEntryBlob
public interface Blob
A blob contains large binary data, and is associated with a MIME type, encoding, and filename. It also has a fixed length, and a digest.This interface requires that implementations of
getStream()
can be called several times, so the first call must not "exhaust" the stream.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description byte[]
getByteArray()
CloseableFile
getCloseableFile()
Gets aCloseableFile
backing this blob, which must be closed when done by the caller.CloseableFile
getCloseableFile(String ext)
Gets aCloseableFile
backing this blob, which must be closed when done by the caller.String
getDigest()
String
getDigestAlgorithm()
String
getEncoding()
File
getFile()
If this blob is backed by an actual file, returns it.String
getFilename()
long
getLength()
Gets the data length in bytes if known.String
getMimeType()
InputStream
getStream()
Gets anInputStream
for the data of this blob.String
getString()
void
setDigest(String digest)
default void
setDigestAlgorithm(String digestAlgorithm)
void
setEncoding(String encoding)
void
setFilename(String filename)
void
setMimeType(String mimeType)
void
transferTo(File file)
void
transferTo(OutputStream out)
-
-
-
Method Detail
-
getStream
InputStream getStream() throws IOException
Gets anInputStream
for the data of this blob.The contract of
Blob
is that this method can be called several times and will correctly return a newInputStream
each time. In other words, several reads of theBlob
can be done.Like all
InputStream
, the result must be closed when done with it to avoid resource leaks.- Returns:
- the stream
- Throws:
IOException
-
getLength
long getLength()
Gets the data length in bytes if known.- Returns:
- the data length or -1 if not known
-
getMimeType
String getMimeType()
-
getEncoding
String getEncoding()
-
getFilename
String getFilename()
-
getDigestAlgorithm
String getDigestAlgorithm()
- Since:
- 7.4
-
getDigest
String getDigest()
-
setMimeType
void setMimeType(String mimeType)
-
setEncoding
void setEncoding(String encoding)
-
setFilename
void setFilename(String filename)
-
setDigestAlgorithm
default void setDigestAlgorithm(String digestAlgorithm)
- Since:
- 11.5
-
setDigest
void setDigest(String digest)
-
getByteArray
byte[] getByteArray() throws IOException
- Throws:
IOException
-
getString
String getString() throws IOException
- Throws:
IOException
-
transferTo
void transferTo(OutputStream out) throws IOException
- Throws:
IOException
-
transferTo
void transferTo(File file) throws IOException
- Throws:
IOException
-
getFile
File getFile()
If this blob is backed by an actual file, returns it.The returned file may be short-lived (temporary), so should be used immediately.
- Returns:
- a file, or
null
if the blob is not backed by a file - Since:
- 7.2
-
getCloseableFile
CloseableFile getCloseableFile() throws IOException
Gets aCloseableFile
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.
- Returns:
- a closeable file, to be closed when done
- Throws:
IOException
- Since:
- 7.2
-
getCloseableFile
CloseableFile getCloseableFile(String ext) throws IOException
Gets aCloseableFile
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.
- Parameters:
ext
- the required extension for the file, ornull
if it doesn't matter- Returns:
- a closeable file, to be closed when done
- Throws:
IOException
- Since:
- 7.2
-
-