com.mongodb.gridfs.GridFS.find()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(277)

本文整理了Java中com.mongodb.gridfs.GridFS.find()方法的一些代码示例,展示了GridFS.find()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridFS.find()方法的具体详情如下:
包路径:com.mongodb.gridfs.GridFS
类名称:GridFS
方法名:find

GridFS.find介绍

[英]Finds a list of files matching the given query.
[中]查找与给定查询匹配的文件列表。

代码示例

代码示例来源:origin: org.mongodb/mongo-java-driver

  1. /**
  2. * Finds a list of files matching the given query.
  3. *
  4. * @param query the filter to apply
  5. * @return list of gridfs files
  6. * @throws com.mongodb.MongoException if the operation fails
  7. */
  8. public List<GridFSDBFile> find(final DBObject query) {
  9. return find(query, null);
  10. }

代码示例来源:origin: org.mongodb/mongo-java-driver

  1. /**
  2. * Finds a list of files matching the given filename.
  3. *
  4. * @param filename the filename to look for
  5. * @return list of gridfs files
  6. * @throws com.mongodb.MongoException if the operation fails
  7. */
  8. public List<GridFSDBFile> find(final String filename) {
  9. return find(new BasicDBObject("filename", filename));
  10. }

代码示例来源:origin: org.mongodb/mongo-java-driver

  1. /**
  2. * Finds a list of files matching the given filename.
  3. *
  4. * @param filename the filename to look for
  5. * @param sort the fields to sort with
  6. * @return list of gridfs files
  7. * @throws com.mongodb.MongoException if the operation fails
  8. */
  9. public List<GridFSDBFile> find(final String filename, final DBObject sort) {
  10. return find(new BasicDBObject("filename", filename), sort);
  11. }

代码示例来源:origin: org.mongodb/mongo-java-driver

  1. /**
  2. * Removes all files matching the given query.
  3. *
  4. * @param query filter to apply
  5. * @throws com.mongodb.MongoException if the operation fails
  6. */
  7. public void remove(final DBObject query) {
  8. if (query == null) {
  9. throw new IllegalArgumentException("query can not be null");
  10. }
  11. for (final GridFSDBFile f : find(query)) {
  12. f.remove();
  13. }
  14. }

代码示例来源:origin: org.mongodb/mongodb-driver

  1. /**
  2. * Finds a list of files matching the given query.
  3. *
  4. * @param query the filter to apply
  5. * @return list of gridfs files
  6. * @throws com.mongodb.MongoException if the operation fails
  7. */
  8. public List<GridFSDBFile> find(final DBObject query) {
  9. return find(query, null);
  10. }

代码示例来源:origin: org.mongodb/mongodb-driver

  1. /**
  2. * Finds a list of files matching the given filename.
  3. *
  4. * @param filename the filename to look for
  5. * @return list of gridfs files
  6. * @throws com.mongodb.MongoException if the operation fails
  7. */
  8. public List<GridFSDBFile> find(final String filename) {
  9. return find(new BasicDBObject("filename", filename));
  10. }

代码示例来源:origin: org.mongodb/mongodb-driver

  1. /**
  2. * Finds a list of files matching the given filename.
  3. *
  4. * @param filename the filename to look for
  5. * @param sort the fields to sort with
  6. * @return list of gridfs files
  7. * @throws com.mongodb.MongoException if the operation fails
  8. */
  9. public List<GridFSDBFile> find(final String filename, final DBObject sort) {
  10. return find(new BasicDBObject("filename", filename), sort);
  11. }

代码示例来源:origin: Kurento/kurento-java

  1. @Override
  2. public RepositoryItem findRepositoryItemById(String id) {
  3. List<GridFSDBFile> dbFiles = gridFS.find(id);
  4. if (dbFiles.size() > 0) {
  5. if (dbFiles.size() > 1) {
  6. log.warn("There are several files with the same " + "filename and should be only one");
  7. }
  8. return createRepositoryItem(dbFiles.get(0));
  9. }
  10. throw new NoSuchElementException("The repository item with id \"" + id + "\" does not exist");
  11. }
  12. //

代码示例来源:origin: org.kurento/kurento-repository-internal

  1. @Override
  2. public RepositoryItem findRepositoryItemById(String id) {
  3. List<GridFSDBFile> dbFiles = gridFS.find(id);
  4. if (dbFiles.size() > 0) {
  5. if (dbFiles.size() > 1) {
  6. log.warn("There are several files with the same " + "filename and should be only one");
  7. }
  8. return createRepositoryItem(dbFiles.get(0));
  9. }
  10. throw new NoSuchElementException("The repository item with id \"" + id + "\" does not exist");
  11. }
  12. //

代码示例来源:origin: org.mongodb.mongo-hadoop/mongo-hadoop-core

  1. private GridFSDBFile getFile() throws IOException {
  2. if (null == file) {
  3. file = getGridFS().find(fileId);
  4. if (null == file) {
  5. throw new IOException("No file found for id " + fileId);
  6. }
  7. }
  8. return file;
  9. }

代码示例来源:origin: org.craftercms/crafter-commons-mongo

  1. @Override
  2. public List<FileInfo> listFilesByName(final String filename){
  3. final List<GridFSDBFile> files = gridfs.find(new BasicDBObject("filename",new BasicDBObject("$regex",
  4. ".*"+filename+".*")));
  5. final ArrayList<FileInfo> toReturn = new ArrayList<FileInfo>();
  6. for (GridFSDBFile file : files) {
  7. toReturn.add(new FileInfo(file,false));
  8. }
  9. return toReturn;
  10. }

代码示例来源:origin: Findwise/Hydra

  1. @Override
  2. public boolean deleteFile(Object id) {
  3. DBObject obj = new BasicDBObject(MongoDocument.MONGO_ID_KEY, id);
  4. if (pipelinefs.find(obj).size()==0) {
  5. return false;
  6. }
  7. pipelinefs.remove(obj);
  8. return true;
  9. }
  10. }

代码示例来源:origin: suninformation/ymate-platform-v2

  1. @Override
  2. public List<GridFSDBFile> find(String filename, OrderBy orderBy) {
  3. return __gridFS.find(filename, orderBy.toBson());
  4. }

代码示例来源:origin: org.kurento/kurento-repository-internal

  1. private List<RepositoryItem> findRepositoryItemsByQuery(String query) {
  2. List<GridFSDBFile> files = gridFS.find((DBObject) JSON.parse(query));
  3. List<RepositoryItem> repositoryItems = new ArrayList<>();
  4. for (GridFSDBFile file : files) {
  5. repositoryItems.add(createRepositoryItem(file));
  6. }
  7. return repositoryItems;
  8. }

代码示例来源:origin: Kurento/kurento-java

  1. private List<RepositoryItem> findRepositoryItemsByQuery(String query) {
  2. List<GridFSDBFile> files = gridFS.find((DBObject) JSON.parse(query));
  3. List<RepositoryItem> repositoryItems = new ArrayList<>();
  4. for (GridFSDBFile file : files) {
  5. repositoryItems.add(createRepositoryItem(file));
  6. }
  7. return repositoryItems;
  8. }

代码示例来源:origin: stackoverflow.com

  1. GridFS gfs = new GridFS(db);
  2. ObjectId fileId = new ObjectId("your_object_id");
  3. GridFSDBFile gfsFile = gfs.find(fileId);
  4. File outFile;
  5. RelativeLayout v = (RelativeLayout) findViewById(R.id.RelativeLayout);
  6. Context context = (Context) v.getContext();
  7. outFile = File.createTempFile("xyz", null, context.getCacheDir());
  8. gfsFile.writeTo(outFile);
  9. ImageView iv= (ImageView)findViewById(R.id.imageView1);
  10. InputStream is = new FileInputStream(outFile);
  11. iv.setImageBitmap(BitmapFactory.decodeStream(is));
  12. outFile.delete();`

代码示例来源:origin: Findwise/Hydra

  1. @Override
  2. @Deprecated
  3. public void removeInactiveFiles() {
  4. BasicDBObject query = new BasicDBObject();
  5. query.put(MongoPipelineReader.ACTIVE_KEY, Stage.Mode.INACTIVE.toString());
  6. List<GridFSDBFile> list = pipelinefs.find(query);
  7. for(GridFSDBFile file : list) {
  8. pipelinefs.remove(file);
  9. }
  10. }

代码示例来源:origin: org.kurento/kurento-repository-internal

  1. @Override
  2. public RepositoryItem createRepositoryItem(String id) {
  3. // TODO The file is not written until outputstream is closed. There is a
  4. // potentially data race with this unique test
  5. if (!gridFS.find(id).isEmpty()) {
  6. throw new DuplicateItemException(id);
  7. }
  8. GridFSInputFile dbFile = gridFS.createFile(id);
  9. dbFile.setId(id);
  10. return createRepositoryItem(dbFile);
  11. }

代码示例来源:origin: Kurento/kurento-java

  1. @Override
  2. public RepositoryItem createRepositoryItem(String id) {
  3. // TODO The file is not written until outputstream is closed. There is a
  4. // potentially data race with this unique test
  5. if (!gridFS.find(id).isEmpty()) {
  6. throw new DuplicateItemException(id);
  7. }
  8. GridFSInputFile dbFile = gridFS.createFile(id);
  9. dbFile.setId(id);
  10. return createRepositoryItem(dbFile);
  11. }

代码示例来源:origin: Findwise/Hydra

  1. @Override
  2. public List<String> getDocumentFileNames(DatabaseDocument<MongoType> d) {
  3. MongoDocument md = (MongoDocument)d;
  4. DBObject query = QueryBuilder.start(DOCUMENT_KEY).is(md.getID().getID()).get();
  5. ArrayList<String> list = new ArrayList<String>();
  6. List<GridFSDBFile> files = documentfs.find(query);
  7. for(GridFSDBFile file : files) {
  8. list.add(file.getFilename());
  9. }
  10. return list;
  11. }

相关文章