Spring Data MongoDB

org.springframework.data.mongodb.gridfs
Interface GridFsOperations

All Superinterfaces:
ResourceLoader, ResourcePatternResolver
All Known Implementing Classes:
GridFsTemplate

public interface GridFsOperations
extends ResourcePatternResolver

Collection of operations to store and read files from MongoDB GridFS.

Author:
Oliver Gierke, Philipp Schneider

Field Summary
 
Fields inherited from interface org.springframework.core.io.support.ResourcePatternResolver
CLASSPATH_ALL_URL_PREFIX
 
Fields inherited from interface org.springframework.core.io.ResourceLoader
CLASSPATH_URL_PREFIX
 
Method Summary
 void delete(Query query)
          Deletes all files matching the given Query.
 List<com.mongodb.gridfs.GridFSDBFile> find(Query query)
          Returns all files matching the given query.
 com.mongodb.gridfs.GridFSDBFile findOne(Query query)
          Returns a single file matching the given query or null in case no file matches.
 GridFsResource getResource(String filename)
          Returns all GridFsResource with the given file name.
 GridFsResource[] getResources(String filenamePattern)
          Returns all GridFsResources matching the given file name pattern.
 com.mongodb.gridfs.GridFSFile store(InputStream content, String filename)
          Stores the given content into a file with the given name.
 com.mongodb.gridfs.GridFSFile store(InputStream content, String filename, com.mongodb.DBObject metadata)
          Stores the given content into a file with the given name using the given metadata.
 com.mongodb.gridfs.GridFSFile store(InputStream content, String filename, Object metadata)
          Stores the given content into a file with the given name using the given metadata.
 com.mongodb.gridfs.GridFSFile store(InputStream content, String filename, String contentType)
          Stores the given content into a file with the given name and content type.
 com.mongodb.gridfs.GridFSFile store(InputStream content, String filename, String contentType, com.mongodb.DBObject metadata)
          Stores the given content into a file with the given name and content type using the given metadata.
 com.mongodb.gridfs.GridFSFile store(InputStream content, String filename, String contentType, Object metadata)
          Stores the given content into a file with the given name and content type using the given metadata.
 
Methods inherited from interface org.springframework.core.io.ResourceLoader
getClassLoader
 

Method Detail

store

com.mongodb.gridfs.GridFSFile store(InputStream content,
                                    String filename)
Stores the given content into a file with the given name.

Parameters:
content - must not be null.
filename - must not be null or empty.
Returns:
the GridFSFile just created

store

com.mongodb.gridfs.GridFSFile store(InputStream content,
                                    String filename,
                                    String contentType)
Stores the given content into a file with the given name and content type.

Parameters:
content - must not be null.
filename - must not be null or empty.
contentType - can be null.
Returns:
the GridFSFile just created

store

com.mongodb.gridfs.GridFSFile store(InputStream content,
                                    String filename,
                                    Object metadata)
Stores the given content into a file with the given name using the given metadata. The metadata object will be marshalled before writing.

Parameters:
content - must not be null.
filename - must not be null or empty.
metadata - can be null.
Returns:
the GridFSFile just created

store

com.mongodb.gridfs.GridFSFile store(InputStream content,
                                    String filename,
                                    String contentType,
                                    Object metadata)
Stores the given content into a file with the given name and content type using the given metadata. The metadata object will be marshalled before writing.

Parameters:
content - must not be null.
filename - must not be null or empty.
contentType - can be null.
metadata - can be null
Returns:
the GridFSFile just created

store

com.mongodb.gridfs.GridFSFile store(InputStream content,
                                    String filename,
                                    com.mongodb.DBObject metadata)
Stores the given content into a file with the given name using the given metadata.

Parameters:
content - must not be null.
filename - must not be null or empty.
metadata - can be null.
Returns:
the GridFSFile just created

store

com.mongodb.gridfs.GridFSFile store(InputStream content,
                                    String filename,
                                    String contentType,
                                    com.mongodb.DBObject metadata)
Stores the given content into a file with the given name and content type using the given metadata.

Parameters:
content - must not be null.
filename - must not be null or empty.
contentType - can be null.
metadata - can be null.
Returns:
the GridFSFile just created

find

List<com.mongodb.gridfs.GridFSDBFile> find(Query query)
Returns all files matching the given query. Note, that currently Sort criterias defined at the Query will not be regarded as MongoDB does not support ordering for GridFS file access.

Parameters:
query -
Returns:
See Also:
https://jira.mongodb.org/browse/JAVA-431

findOne

com.mongodb.gridfs.GridFSDBFile findOne(Query query)
Returns a single file matching the given query or null in case no file matches.

Parameters:
query -
Returns:

delete

void delete(Query query)
Deletes all files matching the given Query.

Parameters:
query -

getResource

GridFsResource getResource(String filename)
Returns all GridFsResource with the given file name.

Specified by:
getResource in interface ResourceLoader
Parameters:
filename -
Returns:
See Also:
ResourceLoader.getResource(String)

getResources

GridFsResource[] getResources(String filenamePattern)
Returns all GridFsResources matching the given file name pattern.

Specified by:
getResources in interface ResourcePatternResolver
Parameters:
filenamePattern -
Returns:
See Also:
ResourcePatternResolver.getResources(String)

Spring Data MongoDB

Copyright © 2011-2013-2013 SpringSource. All Rights Reserved.