Class FileBlob
- java.lang.Object
- 
- org.nuxeo.ecm.core.api.impl.blob.AbstractBlob
- 
- org.nuxeo.ecm.core.api.impl.blob.FileBlob
 
 
- 
- All Implemented Interfaces:
- Serializable,- Blob
 
 public class FileBlob extends AbstractBlob implements Serializable ABlobbacked by aFile.The backing file may be in a temporary location, which is the case if this FileBlobwas constructed from anInputStreamor 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:
- Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected Filefileprotected booleanisTemporary- 
Fields inherited from class org.nuxeo.ecm.core.api.impl.blob.AbstractBlobdigest, digestAlgorithm, encoding, filename, mimeType, TEXT_PLAIN, UTF_8
 
- 
 - 
Constructor SummaryConstructors Constructor Description FileBlob(File file)FileBlob(File file, boolean isTemporary)FileBlob(File file, String mimeType)FileBlob(File file, String mimeType, String encoding)FileBlob(File file, String mimeType, String encoding, String filename, String digest)FileBlob(InputStream in)Creates aFileBlobfrom anInputStream, by saving it to a temporary file.FileBlob(InputStream in, String mimeType)Creates aFileBlobfrom anInputStream, by saving it to a temporary file.FileBlob(InputStream in, String mimeType, String encoding)Creates aFileBlobfrom anInputStream, by saving it to a temporary file.FileBlob(InputStream in, String mimeType, String encoding, File tmpDir)Creates aFileBlobfrom anInputStream, by saving it to a temporary file.FileBlob(String ext)Creates aFileBlobwith an empty temporary file with the given extension.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description FilegetFile()If this blob is backed by an actual file, returns it.longgetLength()Gets the data length in bytes if known.InputStreamgetStream()Gets anInputStreamfor the data of this blob.booleanisTemporary()Checks whether thisFileBlobis backed by a temporary file.voidmoveTo(File dest)Moves this blob's temporary file to a new non-temporary location.- 
Methods inherited from class org.nuxeo.ecm.core.api.impl.blob.AbstractBlobequals, equalsStream, getByteArray, getCloseableFile, getCloseableFile, getDigest, getDigestAlgorithm, getEncoding, getFilename, getMimeType, getString, hashCode, setDigest, setDigestAlgorithm, setEncoding, setFilename, setMimeType, transferTo, transferTo
 
- 
 
- 
- 
- 
Field Detail- 
fileprotected File file 
 - 
isTemporaryprotected boolean isTemporary 
 
- 
 - 
Constructor Detail- 
FileBlobpublic FileBlob(File file) 
 - 
FileBlobpublic FileBlob(File file, String mimeType, String encoding, String filename, String digest) 
 - 
FileBlobpublic FileBlob(InputStream in) throws IOException Creates aFileBlobfrom 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
 
 - 
FileBlobpublic FileBlob(InputStream in, String mimeType) throws IOException Creates aFileBlobfrom anInputStream, by saving it to a temporary file.The input stream is closed. - Parameters:
- in- the input stream, which is closed after use
- mimeType- the MIME type
- Throws:
- IOException
 
 - 
FileBlobpublic FileBlob(InputStream in, String mimeType, String encoding) throws IOException Creates aFileBlobfrom anInputStream, by saving it to a temporary file.The input stream is closed. - Parameters:
- in- the input stream, which is closed after use
- mimeType- the MIME type
- encoding- the encoding
- Throws:
- IOException
 
 - 
FileBlobpublic FileBlob(InputStream in, String mimeType, String encoding, File tmpDir) throws IOException Creates aFileBlobfrom anInputStream, by saving it to a temporary file.The input stream is closed. - Parameters:
- in- the input stream, which is closed after use
- mimeType- the MIME type
- encoding- the encoding
- tmpDir- the temporary directory for file creation
- Throws:
- IOException
 
 - 
FileBlobpublic FileBlob(String ext) throws IOException Creates aFileBlobwith an empty temporary file with the given extension.- Parameters:
- ext- the temporary file extension
- Throws:
- IOException
- Since:
- 7.2
 
 - 
FileBlobpublic FileBlob(File file, boolean isTemporary) - Since:
- 10.3
 
 
- 
 - 
Method Detail- 
getFilepublic 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. - Specified by:
- getFilein interface- Blob
- Overrides:
- getFilein class- AbstractBlob
- Returns:
- a file, or nullif the blob is not backed by a file
 
 - 
getLengthpublic long getLength() Description copied from interface:BlobGets the data length in bytes if known.- Specified by:
- getLengthin interface- Blob
- Overrides:
- getLengthin class- AbstractBlob
- Returns:
- the data length or -1 if not known
 
 - 
getStreampublic 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 interface- Blob
- Returns:
- the stream
- Throws:
- IOException
 
 - 
isTemporarypublic boolean isTemporary() Checks whether thisFileBlobis backed by a temporary file.- Since:
- 7.2
 
 - 
moveTopublic void moveTo(File dest) throws IOException 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
 
 
- 
 
-