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

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

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

GridFS.getBucketName介绍

[英]Gets the bucket name used in the collection's namespace. Default value is 'fs'.
[中]获取集合命名空间中使用的存储桶名称。默认值为“fs”。

代码示例

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

/**
 * Verifies that the MD5 matches between the database and the local file. This should be called after transferring a file.
 *
 * @throws MongoException if there's a failure
 * @deprecated there is no replacement for this method
 */
@Deprecated
public void validate() {
  if (fs == null) {
    throw new MongoException("no fs");
  }
  if (md5 == null) {
    throw new MongoException("no md5 stored");
  }
  DBObject cmd = new BasicDBObject("filemd5", id);
  cmd.put("root", fs.getBucketName());
  DBObject res = fs.getDB().command(cmd);
  if (res != null && res.containsField("md5")) {
    String m = res.get("md5").toString();
    if (m.equals(md5)) {
      return;
    }
    throw new MongoException("md5 differ.  mine [" + md5 + "] theirs [" + m + "]");
  }
  // no md5 from the server
  throw new MongoException("no md5 returned from server: " + res);
}

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

/**
 * Verifies that the MD5 matches between the database and the local file. This should be called after transferring a file.
 *
 * @throws MongoException if there's a failure
 * @deprecated there is no replacement for this method
 */
@Deprecated
public void validate() {
  if (fs == null) {
    throw new MongoException("no fs");
  }
  if (md5 == null) {
    throw new MongoException("no md5 stored");
  }
  DBObject cmd = new BasicDBObject("filemd5", id);
  cmd.put("root", fs.getBucketName());
  DBObject res = fs.getDB().command(cmd);
  if (res != null && res.containsField("md5")) {
    String m = res.get("md5").toString();
    if (m.equals(md5)) {
      return;
    }
    throw new MongoException("md5 differ.  mine [" + md5 + "] theirs [" + m + "]");
  }
  // no md5 from the server
  throw new MongoException("no md5 returned from server: " + res);
}

相关文章