public class GridFsResource extends InputStreamResource
GridFSFile
based Resource
implementation.Constructor and Description |
---|
GridFsResource(com.mongodb.client.gridfs.model.GridFSFile file)
Creates a new
GridFsResource from the given GridFSFile . |
GridFsResource(com.mongodb.client.gridfs.model.GridFSFile file,
InputStream inputStream)
|
Modifier and Type | Method and Description |
---|---|
static GridFsResource |
absent(String filename)
Obtain an absent
GridFsResource . |
long |
contentLength() |
boolean |
exists() |
String |
getContentType()
Returns the
Resource 's content type. |
String |
getDescription() |
String |
getFilename() |
com.mongodb.client.gridfs.model.GridFSFile |
getGridFSFile() |
Object |
getId()
Returns the
Resource 's id. |
InputStream |
getInputStream() |
long |
lastModified() |
equals, hashCode, isOpen
createRelative, getFile, getFileForLastModifiedCheck, getURI, getURL, isFile, isReadable, readableChannel, toString
public GridFsResource(com.mongodb.client.gridfs.model.GridFSFile file)
GridFsResource
from the given GridFSFile
.file
- must not be null.public GridFsResource(com.mongodb.client.gridfs.model.GridFSFile file, InputStream inputStream)
file
- must not be null.inputStream
- must not be null.public static GridFsResource absent(String filename)
GridFsResource
.filename
- filename of the absent resource, must not be null.public InputStream getInputStream() throws IOException, IllegalStateException
getInputStream
in interface InputStreamSource
getInputStream
in class InputStreamResource
IOException
IllegalStateException
public long contentLength() throws IOException
contentLength
in interface Resource
contentLength
in class AbstractResource
IOException
public String getFilename() throws IllegalStateException
getFilename
in interface Resource
getFilename
in class AbstractResource
IllegalStateException
public boolean exists()
exists
in interface Resource
exists
in class InputStreamResource
public long lastModified() throws IOException
lastModified
in interface Resource
lastModified
in class AbstractResource
IOException
public String getDescription()
getDescription
in interface Resource
getDescription
in class InputStreamResource
public Object getId()
Resource
's id.IllegalStateException
- if the file does not exists()
.@Nullable public com.mongodb.client.gridfs.model.GridFSFile getGridFSFile()
GridFSFile
. Can be null if absent.public String getContentType()
Resource
's content type.com.mongodb.MongoGridFSException
- in case no content type declared on GridFSFile.getMetadata()
nor
provided via GridFSFile.getContentType()
.IllegalStateException
- if the file does not exists()
.Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.