public class BlobWrapper extends Object implements Blob, Serializable
Blob
to allow setting a different filename.Modifier and Type | Field and Description |
---|---|
protected Blob |
blob |
protected String |
filename |
Constructor and Description |
---|
BlobWrapper(Blob blob) |
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) |
public BlobWrapper(Blob blob)
public String getFilename()
getFilename
in interface Blob
public void setFilename(String filename)
setFilename
in interface Blob
public String getMimeType()
getMimeType
in interface Blob
public String getEncoding()
getEncoding
in interface Blob
public String getDigestAlgorithm()
getDigestAlgorithm
in interface Blob
public void setMimeType(String mimeType)
setMimeType
in interface Blob
public void setEncoding(String encoding)
setEncoding
in interface Blob
public InputStream getStream() throws IOException
Blob
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.
getStream
in interface Blob
IOException
public long getLength()
Blob
public byte[] getByteArray() throws IOException
getByteArray
in interface Blob
IOException
public String getString() throws IOException
getString
in interface Blob
IOException
public void transferTo(OutputStream out) throws IOException
transferTo
in interface Blob
IOException
public void transferTo(File file) throws IOException
transferTo
in interface Blob
IOException
public File getFile()
Blob
The returned file may be short-lived (temporary), so should be used immediately.
public CloseableFile getCloseableFile() throws IOException
Blob
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.
getCloseableFile
in interface Blob
IOException
public CloseableFile getCloseableFile(String ext) throws IOException
Blob
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.
getCloseableFile
in interface Blob
ext
- the required extension for the file, or null
if it doesn't matterIOException
Copyright © 2018 Nuxeo. All rights reserved.