本文整理匯總了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());
}
}