返回介绍

1.10.2 Bucket操作API的签名和示例

发布于 2020-10-01 16:22:04 字数 6251 浏览 905 评论 0 收藏 0

PUT Bucket

函数签名
/**
* Creates a new fds bucket with the specified name.
*
* @param bucketName The name of the bucket to create
* @throws GalaxyFDSClientException
*/
public void createBucket(String bucketName) throws GalaxyFDSClientException;
示例
fdsClient.createBucket(BUCKET_NAME);

DELETE Bucket

函数签名
/**
* Deletes a fds bucket with the specified name.
*
* @param bucketName The name of the bucket to delete
* @throws GalaxyFDSClientException
*/
public void deleteBucket(String bucketName) throws GalaxyFDSClientException;
示例
fdsClient.deleteBucket(BUCKET_NAME);

HEAD Bucket

函数签名
/**
* Checks if the specified bucket exists.
*
* @param bucketName The name of the bucket to check
* @return The value true if the specified bucket exists, otherwise false
* @throws GalaxyFDSClientException
*/
public boolean doesBucketExist(String bucketName)
  throws GalaxyFDSClientException;
示例
boolean exist = fdsClient.doesBucketExist(BUCKET_NAME);

PUT Bucket ACL

函数签名
/**
* Sets the AccessControlList(ACL) of the specified fds bucket.
*
* @param bucketName The name of the bucket whoses acl is being set
* @param acl        The new AccessControlList for the specified bucket
* @throws GalaxyFDSClientException
*/
public void setBucketAcl(String bucketName, AccessControlList acl)
  throws GalaxyFDSClientException;
示例
AccessControlList acl = new AccessControlList();
Grant grant = new Grant("12346", Permission.READ, GrantType.USER);
acl.addGrant(grant);
fdsClient.setBucketAcl(BUCKET_NAME, acl);

GET Bucket ACL

函数签名
/**
* Gets the AccessControlList(ACL) of the specified fds bucket.
*
* @param bucketName The name of the bucket whose ACL is being retrieved
* @return The AccessControlList for the specified bucket
* @throws GalaxyFDSClientException
*/
public AccessControlList getBucketAcl(String bucketName)
  throws GalaxyFDSClientException;
示例
AccessControlList acl = fdsClient.getBucketAcl(BUCKET_NAME);
for (Grant grant : acl.getGrantList()) {
  System.out.println("grantee: " + grant.getGranteeId() + ", permission: "
      + grant.getPermission() + ", type: " + grant.getType());
}

List Objects

函数签名
/**
* Returns a list of summary information about the objects in the specified
* fds bucket.
* <p/>
* Because buckets can contain a virtually unlimited number of keys, the
* complete results of a list query can be extremely large. To manage large
* result sets, galaxy fds uses pagination to split them into multiple
* responses. Always check the {@link #FDSObjectListing.isTruncated()} method
* to see if the returned listing is complete or if additional calls are
* needed to get more results. Alternatively, use the
* {@link #listNextBatchOfObjects(FDSObjectListing)} method as an easy way to
* get the next page of object listings.
*
* @param bucketName The name of the bucket to list
* @return A listing of the objects in the specified bucket
* @throws GalaxyFDSClientException
*/
public FDSObjectListing listObjects(String bucketName)
  throws GalaxyFDSClientException;

/**
* Returns a list of summary information about the objects in the specified
* fds bucket.
*
* @param bucketName The name of the bucket to list
* @param prefix     An optional parameter restricting the response to keys
*                   beginning with the specified prefix.
* @return A listing of the objects in the specified bucket
* @throws GalaxyFDSClientException
*/
public FDSObjectListing listObjects(String bucketName, String prefix)
  throws GalaxyFDSClientException;

/**
* Returns a list of summary information about the objects in the specified
* fds bucket.
*
* @param bucketName The name of the bucket to list
* @param prefix     An optional parameter restricting the response to keys
*                   beginning with the specified prefix.
* @param delimiter  delimiter to separate path
* @return A listing of the objects in the specified bucket
* @throws GalaxyFDSClientException
*/
public FDSObjectListing listObjects(String bucketName, String prefix,
  String delimiter) throws GalaxyFDSClientException;

/**
* Provides an easy way to continue a truncated object listing and retrieve
* the next page of results.
*
* @param previousObjectListing The previous truncated ObjectListing
* @return The next set of ObjectListing results, beginning immediately after
*         the last result in the specified previous ObjectListing.
* @throws GalaxyFDSClientException
*/
public FDSObjectListing listNextBatchOfObjects(
  FDSObjectListing previousObjectListing) throws GalaxyFDSClientException;
示例
FDSObjectListing listing = null;
do {
  if (listing == null) {
    listing = fdsClient.listObjects(bucketName, "", "/");
  } else {
    listing = fdsClient.listNextBatchOfObjects(listing);
  }
  if (listing != null) {
    List<String> commonPrefixes = listing.getCommonPrefixes();
    for (String commonPrefix : commonPrefixes) {
      System.out.println(commonPrefix);
    }
    List<FDSObjectSummary> objectSummaries = listing.getObjectSummaries();
    for (FDSObjectSummary objectSummary : objectSummaries) {
      System.out.println(objectSummary.getObjectName());
    }
  }
}
while (listing != null && listing.isTruncated());

Note

更多例子,请参考List Objects REST API

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文