本文整理了Java中com.google.cloud.storage.Blob.createAcl()
方法的一些代码示例,展示了Blob.createAcl()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Blob.createAcl()
方法的具体详情如下:
包路径:com.google.cloud.storage.Blob
类名称:Blob
方法名:createAcl
[英]Creates a new ACL entry on this blob.
Example of creating a new ACL entry.
Acl acl = blob.createAcl(Acl.of(User.ofAllAuthenticatedUsers(), Acl.Role.READER));
[中]在此blob上创建新的ACL条目。
创建新ACL条目的示例。
Acl acl = blob.createAcl(Acl.of(User.ofAllAuthenticatedUsers(), Acl.Role.READER));
代码示例来源:origin: googleapis/google-cloud-java
/** Example of creating a new ACL entry. */
// [TARGET createAcl(Acl)]
public Acl createAcl() {
// [START createAcl]
Acl acl = blob.createAcl(Acl.of(User.ofAllAuthenticatedUsers(), Acl.Role.READER));
// [END createAcl]
return acl;
}
代码示例来源:origin: googleapis/google-cloud-java
/**
* Sets the ACL according to the provided {@code params}, using the {@code storage} service. If
* {@code params.x()} returns a complete blob identity, the {@code params.y()} ACL is added to
* the blob. If {@code params.x().name()} is empty, the {@code params.y()} ACL is added to the
* bucket identified by {@code params.x().bucket()}.
*/
@Override
public void run(Storage storage, Tuple<BlobId, Acl> params) {
BlobId blobId = params.x();
Acl acl = params.y();
if (blobId.getName().isEmpty()) {
Bucket bucket = storage.get(blobId.getBucket());
if (bucket == null) {
System.out.printf("Bucket %s does not exist%n", blobId.getBucket());
return;
}
acl = bucket.createAcl(acl);
System.out.printf("Added ACL %s to bucket %s%n", acl, blobId.getBucket());
} else {
Blob blob = storage.get(blobId);
if (blob == null) {
System.out.printf("Blob %s does not exist%n", blobId);
return;
}
acl = blob.createAcl(acl);
System.out.printf("Added ACL %s to blob %s%n", acl, blobId);
}
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testCreateAcl() throws Exception {
initializeExpectedBlob(1);
expect(storage.getOptions()).andReturn(mockOptions);
Acl returnedAcl = ACL.toBuilder().setEtag("ETAG").setId("ID").build();
expect(storage.createAcl(BLOB_INFO.getBlobId(), ACL)).andReturn(returnedAcl);
replay(storage);
initializeBlob();
assertEquals(returnedAcl, blob.createAcl(ACL));
}
内容来源于网络,如有侵权,请联系作者删除!