本文整理了Java中com.mongodb.gridfs.GridFS.find()
方法的一些代码示例,展示了GridFS.find()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridFS.find()
方法的具体详情如下:
包路径:com.mongodb.gridfs.GridFS
类名称:GridFS
方法名:find
[英]Finds a list of files matching the given query.
[中]查找与给定查询匹配的文件列表。
代码示例来源:origin: org.mongodb/mongo-java-driver
/**
* Finds a list of files matching the given query.
*
* @param query the filter to apply
* @return list of gridfs files
* @throws com.mongodb.MongoException if the operation fails
*/
public List<GridFSDBFile> find(final DBObject query) {
return find(query, null);
}
代码示例来源:origin: org.mongodb/mongo-java-driver
/**
* Finds a list of files matching the given filename.
*
* @param filename the filename to look for
* @return list of gridfs files
* @throws com.mongodb.MongoException if the operation fails
*/
public List<GridFSDBFile> find(final String filename) {
return find(new BasicDBObject("filename", filename));
}
代码示例来源:origin: org.mongodb/mongo-java-driver
/**
* Finds a list of files matching the given filename.
*
* @param filename the filename to look for
* @param sort the fields to sort with
* @return list of gridfs files
* @throws com.mongodb.MongoException if the operation fails
*/
public List<GridFSDBFile> find(final String filename, final DBObject sort) {
return find(new BasicDBObject("filename", filename), sort);
}
代码示例来源:origin: org.mongodb/mongo-java-driver
/**
* Removes all files matching the given query.
*
* @param query filter to apply
* @throws com.mongodb.MongoException if the operation fails
*/
public void remove(final DBObject query) {
if (query == null) {
throw new IllegalArgumentException("query can not be null");
}
for (final GridFSDBFile f : find(query)) {
f.remove();
}
}
代码示例来源:origin: org.mongodb/mongodb-driver
/**
* Finds a list of files matching the given query.
*
* @param query the filter to apply
* @return list of gridfs files
* @throws com.mongodb.MongoException if the operation fails
*/
public List<GridFSDBFile> find(final DBObject query) {
return find(query, null);
}
代码示例来源:origin: org.mongodb/mongodb-driver
/**
* Finds a list of files matching the given filename.
*
* @param filename the filename to look for
* @return list of gridfs files
* @throws com.mongodb.MongoException if the operation fails
*/
public List<GridFSDBFile> find(final String filename) {
return find(new BasicDBObject("filename", filename));
}
代码示例来源:origin: org.mongodb/mongodb-driver
/**
* Finds a list of files matching the given filename.
*
* @param filename the filename to look for
* @param sort the fields to sort with
* @return list of gridfs files
* @throws com.mongodb.MongoException if the operation fails
*/
public List<GridFSDBFile> find(final String filename, final DBObject sort) {
return find(new BasicDBObject("filename", filename), sort);
}
代码示例来源:origin: Kurento/kurento-java
@Override
public RepositoryItem findRepositoryItemById(String id) {
List<GridFSDBFile> dbFiles = gridFS.find(id);
if (dbFiles.size() > 0) {
if (dbFiles.size() > 1) {
log.warn("There are several files with the same " + "filename and should be only one");
}
return createRepositoryItem(dbFiles.get(0));
}
throw new NoSuchElementException("The repository item with id \"" + id + "\" does not exist");
}
//
代码示例来源:origin: org.kurento/kurento-repository-internal
@Override
public RepositoryItem findRepositoryItemById(String id) {
List<GridFSDBFile> dbFiles = gridFS.find(id);
if (dbFiles.size() > 0) {
if (dbFiles.size() > 1) {
log.warn("There are several files with the same " + "filename and should be only one");
}
return createRepositoryItem(dbFiles.get(0));
}
throw new NoSuchElementException("The repository item with id \"" + id + "\" does not exist");
}
//
代码示例来源:origin: org.mongodb.mongo-hadoop/mongo-hadoop-core
private GridFSDBFile getFile() throws IOException {
if (null == file) {
file = getGridFS().find(fileId);
if (null == file) {
throw new IOException("No file found for id " + fileId);
}
}
return file;
}
代码示例来源:origin: org.craftercms/crafter-commons-mongo
@Override
public List<FileInfo> listFilesByName(final String filename){
final List<GridFSDBFile> files = gridfs.find(new BasicDBObject("filename",new BasicDBObject("$regex",
".*"+filename+".*")));
final ArrayList<FileInfo> toReturn = new ArrayList<FileInfo>();
for (GridFSDBFile file : files) {
toReturn.add(new FileInfo(file,false));
}
return toReturn;
}
代码示例来源:origin: Findwise/Hydra
@Override
public boolean deleteFile(Object id) {
DBObject obj = new BasicDBObject(MongoDocument.MONGO_ID_KEY, id);
if (pipelinefs.find(obj).size()==0) {
return false;
}
pipelinefs.remove(obj);
return true;
}
}
代码示例来源:origin: suninformation/ymate-platform-v2
@Override
public List<GridFSDBFile> find(String filename, OrderBy orderBy) {
return __gridFS.find(filename, orderBy.toBson());
}
代码示例来源:origin: org.kurento/kurento-repository-internal
private List<RepositoryItem> findRepositoryItemsByQuery(String query) {
List<GridFSDBFile> files = gridFS.find((DBObject) JSON.parse(query));
List<RepositoryItem> repositoryItems = new ArrayList<>();
for (GridFSDBFile file : files) {
repositoryItems.add(createRepositoryItem(file));
}
return repositoryItems;
}
代码示例来源:origin: Kurento/kurento-java
private List<RepositoryItem> findRepositoryItemsByQuery(String query) {
List<GridFSDBFile> files = gridFS.find((DBObject) JSON.parse(query));
List<RepositoryItem> repositoryItems = new ArrayList<>();
for (GridFSDBFile file : files) {
repositoryItems.add(createRepositoryItem(file));
}
return repositoryItems;
}
代码示例来源:origin: stackoverflow.com
GridFS gfs = new GridFS(db);
ObjectId fileId = new ObjectId("your_object_id");
GridFSDBFile gfsFile = gfs.find(fileId);
File outFile;
RelativeLayout v = (RelativeLayout) findViewById(R.id.RelativeLayout);
Context context = (Context) v.getContext();
outFile = File.createTempFile("xyz", null, context.getCacheDir());
gfsFile.writeTo(outFile);
ImageView iv= (ImageView)findViewById(R.id.imageView1);
InputStream is = new FileInputStream(outFile);
iv.setImageBitmap(BitmapFactory.decodeStream(is));
outFile.delete();`
代码示例来源:origin: Findwise/Hydra
@Override
@Deprecated
public void removeInactiveFiles() {
BasicDBObject query = new BasicDBObject();
query.put(MongoPipelineReader.ACTIVE_KEY, Stage.Mode.INACTIVE.toString());
List<GridFSDBFile> list = pipelinefs.find(query);
for(GridFSDBFile file : list) {
pipelinefs.remove(file);
}
}
代码示例来源:origin: org.kurento/kurento-repository-internal
@Override
public RepositoryItem createRepositoryItem(String id) {
// TODO The file is not written until outputstream is closed. There is a
// potentially data race with this unique test
if (!gridFS.find(id).isEmpty()) {
throw new DuplicateItemException(id);
}
GridFSInputFile dbFile = gridFS.createFile(id);
dbFile.setId(id);
return createRepositoryItem(dbFile);
}
代码示例来源:origin: Kurento/kurento-java
@Override
public RepositoryItem createRepositoryItem(String id) {
// TODO The file is not written until outputstream is closed. There is a
// potentially data race with this unique test
if (!gridFS.find(id).isEmpty()) {
throw new DuplicateItemException(id);
}
GridFSInputFile dbFile = gridFS.createFile(id);
dbFile.setId(id);
return createRepositoryItem(dbFile);
}
代码示例来源:origin: Findwise/Hydra
@Override
public List<String> getDocumentFileNames(DatabaseDocument<MongoType> d) {
MongoDocument md = (MongoDocument)d;
DBObject query = QueryBuilder.start(DOCUMENT_KEY).is(md.getID().getID()).get();
ArrayList<String> list = new ArrayList<String>();
List<GridFSDBFile> files = documentfs.find(query);
for(GridFSDBFile file : files) {
list.add(file.getFilename());
}
return list;
}
内容来源于网络,如有侵权,请联系作者删除!