Class FileBlob
- All Implemented Interfaces:
Serializable
,Blob
Blob
backed by a File
.
The backing file may be in a temporary location, which is the case if this FileBlob
was constructed from an
InputStream
or from a file which was explicitly marked as temporary. In this case, the file may be renamed,
or the file location may be changed to a non-temporary one.
- See Also:
-
Field Summary
Fields inherited from class org.nuxeo.ecm.core.api.impl.blob.AbstractBlob
digest, digestAlgorithm, encoding, filename, mimeType, TEXT_PLAIN, UTF_8
-
Constructor Summary
ConstructorDescriptionFileBlob
(InputStream in) Creates aFileBlob
from anInputStream
, by saving it to a temporary file.FileBlob
(InputStream in, String mimeType) Creates aFileBlob
from anInputStream
, by saving it to a temporary file.FileBlob
(InputStream in, String mimeType, String encoding) Creates aFileBlob
from anInputStream
, by saving it to a temporary file.FileBlob
(InputStream in, String mimeType, String encoding, File tmpDir) Creates aFileBlob
from anInputStream
, by saving it to a temporary file.Creates aFileBlob
with an empty temporary file with the given extension. -
Method Summary
Modifier and TypeMethodDescriptiongetFile()
If this blob is backed by an actual file, returns it.long
Gets the data length in bytes if known.Gets anInputStream
for the data of this blob.boolean
Checks whether thisFileBlob
is backed by a temporary file.void
Moves this blob's temporary file to a new non-temporary location.Methods inherited from class org.nuxeo.ecm.core.api.impl.blob.AbstractBlob
equals, equalsStream, getByteArray, getCloseableFile, getCloseableFile, getDigest, getDigestAlgorithm, getEncoding, getFilename, getMimeType, getString, hashCode, setDigest, setDigestAlgorithm, setEncoding, setFilename, setMimeType, transferTo, transferTo
-
Field Details
-
file
-
isTemporary
protected boolean isTemporary
-
-
Constructor Details
-
FileBlob
-
FileBlob
-
FileBlob
-
FileBlob
-
FileBlob
Creates aFileBlob
from anInputStream
, by saving it to a temporary file.The input stream is closed.
- Parameters:
in
- the input stream, which is closed after use- Throws:
IOException
-
FileBlob
Creates aFileBlob
from anInputStream
, by saving it to a temporary file.The input stream is closed.
- Parameters:
in
- the input stream, which is closed after usemimeType
- the MIME type- Throws:
IOException
-
FileBlob
Creates aFileBlob
from anInputStream
, by saving it to a temporary file.The input stream is closed.
- Parameters:
in
- the input stream, which is closed after usemimeType
- the MIME typeencoding
- the encoding- Throws:
IOException
-
FileBlob
Creates aFileBlob
from anInputStream
, by saving it to a temporary file.The input stream is closed.
- Parameters:
in
- the input stream, which is closed after usemimeType
- the MIME typeencoding
- the encodingtmpDir
- the temporary directory for file creation- Throws:
IOException
-
FileBlob
Creates aFileBlob
with an empty temporary file with the given extension.- Parameters:
ext
- the temporary file extension- Throws:
IOException
- Since:
- 7.2
-
FileBlob
- Since:
- 10.3
-
-
Method Details
-
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 interfaceBlob
- Overrides:
getFile
in classAbstractBlob
- Returns:
- a file, or
null
if the blob is not backed by a file
-
getLength
public long getLength()Description copied from interface:Blob
Gets the data length in bytes if known.- Specified by:
getLength
in interfaceBlob
- Overrides:
getLength
in classAbstractBlob
- Returns:
- the data length or -1 if not known
-
getStream
Description copied from interface:Blob
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.- Specified by:
getStream
in interfaceBlob
- Returns:
- the stream
- Throws:
IOException
-
isTemporary
public boolean isTemporary()Checks whether thisFileBlob
is backed by a temporary file.- Since:
- 7.2
-
moveTo
Moves this blob's temporary file to a new non-temporary location.The move is done as atomically as possible.
- Throws:
IOException
- Since:
- 7.2
-