public class GridFsResource extends InputStreamResource implements GridFsObject<Object,InputStream>
GridFSFile based Resource implementation.GridFsObject.Options| 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() |
InputStream |
getContent()
The actual file content.
|
String |
getContentType()
Returns the
Resource's content type. |
String |
getDescription() |
Object |
getFileId()
The
GridFSFile.getId() value converted into its simple java type. |
String |
getFilename()
The filename.
|
com.mongodb.client.gridfs.model.GridFSFile |
getGridFSFile() |
Object |
getId()
Returns the
Resource's id. |
InputStream |
getInputStream() |
GridFsObject.Options |
getOptions()
Additional information like file metadata (eg. contentType).
|
long |
lastModified() |
equals, hashCode, isOpencreateRelative, getFile, getFileForLastModifiedCheck, getURI, getURL, isFile, isReadable, readableChannel, toStringpublic 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 InputStreamSourcegetInputStream in class InputStreamResourceIOExceptionIllegalStateExceptionpublic long contentLength()
throws IOException
contentLength in interface ResourcecontentLength in class AbstractResourceIOExceptionpublic String getFilename() throws IllegalStateException
GridFsObjectgetFilename in interface ResourcegetFilename in interface GridFsObject<Object,InputStream>getFilename in class AbstractResourceIllegalStateExceptionpublic boolean exists()
exists in interface Resourceexists in class InputStreamResourcepublic long lastModified()
throws IOException
lastModified in interface ResourcelastModified in class AbstractResourceIOExceptionpublic String getDescription()
getDescription in interface ResourcegetDescription in class InputStreamResourcepublic Object getId()
Resource's id.IllegalStateException - if the file does not exists().public Object getFileId()
GridFsObjectGridFSFile.getId() value converted into its simple java type. BsonString will be converted to plain String.getFileId in interface GridFsObject<Object,InputStream>@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.IllegalStateException - if the file does not exists().public InputStream getContent()
GridFsObjectgetContent in interface GridFsObject<Object,InputStream>public GridFsObject.Options getOptions()
GridFsObjectgetOptions in interface GridFsObject<Object,InputStream>Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.