本文整理汇总了Java中com.amazonaws.services.s3.model.EmailAddressGrantee类的典型用法代码示例。如果您正苦于以下问题:Java EmailAddressGrantee类的具体用法?Java EmailAddressGrantee怎么用?Java EmailAddressGrantee使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EmailAddressGrantee类属于com.amazonaws.services.s3.model包,在下文中一共展示了EmailAddressGrantee类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setBucketAcl
import com.amazonaws.services.s3.model.EmailAddressGrantee; //导入依赖的package包/类
public static void setBucketAcl(String bucket_name, String email, String access)
{
System.out.format("Setting %s access for %s\n", access, email);
System.out.println("on bucket: " + bucket_name);
final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient();
try {
// get the current ACL
AccessControlList acl = s3.getBucketAcl(bucket_name);
// set access for the grantee
EmailAddressGrantee grantee = new EmailAddressGrantee(email);
Permission permission = Permission.valueOf(access);
acl.grantPermission(grantee, permission);
s3.setBucketAcl(bucket_name, acl);
} catch (AmazonServiceException e) {
System.err.println(e.getErrorMessage());
System.exit(1);
}
}
示例2: setObjectAcl
import com.amazonaws.services.s3.model.EmailAddressGrantee; //导入依赖的package包/类
public static void setObjectAcl(String bucket_name, String object_key, String email, String access)
{
System.out.format("Setting %s access for %s\n", access, email);
System.out.println("for object: " + object_key);
System.out.println(" in bucket: " + bucket_name);
final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient();
try {
// get the current ACL
AccessControlList acl = s3.getObjectAcl(bucket_name, object_key);
// set access for the grantee
EmailAddressGrantee grantee = new EmailAddressGrantee(email);
Permission permission = Permission.valueOf(access);
acl.grantPermission(grantee, permission);
s3.setObjectAcl(bucket_name, object_key, acl);
} catch (AmazonServiceException e) {
System.err.println(e.getErrorMessage());
System.exit(1);
}
}
示例3: convertToXml
import com.amazonaws.services.s3.model.EmailAddressGrantee; //导入依赖的package包/类
/**
* Returns an XML fragment representing the specified Grantee.
*
* @param grantee
* The grantee to convert to an XML representation that can be
* sent to Amazon S3 as part of a request.
* @param xml
* The XmlWriter to which to concatenate this node to.
*
* @return The given XmlWriter containing the specified grantee.
*
* @throws SdkClientException
* If the specified grantee type isn't recognized.
*/
protected XmlWriter convertToXml(Grantee grantee, XmlWriter xml) throws SdkClientException {
if (grantee instanceof CanonicalGrantee) {
return convertToXml((CanonicalGrantee)grantee, xml);
} else if (grantee instanceof EmailAddressGrantee) {
return convertToXml((EmailAddressGrantee)grantee, xml);
} else if (grantee instanceof GroupGrantee) {
return convertToXml((GroupGrantee)grantee, xml);
} else {
throw new SdkClientException("Unknown Grantee type: " + grantee.getClass().getName());
}
}