public interface Blob
This interface requires that implementations of getStream()
can be called several times, so the first call
must not "exhaust" the stream.
Modifier and Type | Method and Description |
---|---|
byte[] |
getByteArray() |
CloseableFile |
getCloseableFile()
Gets a
CloseableFile backing this blob, which must be closed when done by the caller. |
CloseableFile |
getCloseableFile(String ext)
Gets a
CloseableFile 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 an
InputStream for the data of this blob. |
String |
getString() |
void |
setDigest(String digest) |
void |
setEncoding(String encoding) |
void |
setFilename(String filename) |
void |
setMimeType(String mimeType) |
void |
transferTo(File file) |
void |
transferTo(OutputStream out) |
InputStream getStream() throws IOException
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.
IOException
long getLength()
String getMimeType()
String getEncoding()
String getFilename()
String getDigestAlgorithm()
void setMimeType(String mimeType)
void setEncoding(String encoding)
void setFilename(String filename)
byte[] getByteArray() throws IOException
IOException
String getString() throws IOException
IOException
void transferTo(OutputStream out) throws IOException
IOException
void transferTo(File file) throws IOException
IOException
File getFile()
The returned file may be short-lived (temporary), so should be used immediately.
null
if the blob is not backed by a fileCloseableFile getCloseableFile() throws IOException
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.
IOException
CloseableFile getCloseableFile(String ext) throws IOException
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.
ext
- the required extension for the file, or null
if it doesn't matterIOException
Copyright © 2017 Nuxeo. All rights reserved.