本文整理汇总了Java中com.amazonaws.services.s3.model.GroupGrantee类的典型用法代码示例。如果您正苦于以下问题:Java GroupGrantee类的具体用法?Java GroupGrantee怎么用?Java GroupGrantee使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GroupGrantee类属于com.amazonaws.services.s3.model包,在下文中一共展示了GroupGrantee类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: init
import com.amazonaws.services.s3.model.GroupGrantee; //导入依赖的package包/类
@Override
public void init(Configuration conf, String keyPrefix) {
bucketName = conf.get(keyPrefix + S3_BUCKET_NAME);
String endpoint = conf.get(keyPrefix + S3_ENDPOINT_NAME);
String key = conf.get(keyPrefix + S3_ACCESS_KEY);
String secret = conf.get(keyPrefix + S3_ACCESS_SECRET);
System.setProperty(SDKGlobalConfiguration.ACCESS_KEY_SYSTEM_PROPERTY, key);
System.setProperty(SDKGlobalConfiguration.SECRET_KEY_SYSTEM_PROPERTY, secret);
AWSCredentialsProvider provider = new SystemPropertiesCredentialsProvider();
client = new AmazonS3Client(provider);
client.setEndpoint(endpoint);
override = conf.getBoolean(keyPrefix + "override", true);
acls = new AccessControlList();
acls.grantPermission(GroupGrantee.AllUsers, Permission.FullControl);
acls.grantPermission(GroupGrantee.AllUsers, Permission.Read);
acls.grantPermission(GroupGrantee.AllUsers, Permission.Write);
}
开发者ID:XiaoMi,项目名称:galaxy-fds-migration-tool,代码行数:19,代码来源:S3Source.java
示例2: uploadToAmazonS3
import com.amazonaws.services.s3.model.GroupGrantee; //导入依赖的package包/类
static public void uploadToAmazonS3(HttpSession session, File fileToUpload) throws S3Exception
{
try
{
AmazonS3 s3client = getS3();
String bucketName = getDownloadS3Bucket();
if(!s3client.doesBucketExist(bucketName))
SagLogger.logError(session, "Does not exist? S3 Bucket :" + bucketName);
AccessControlList acl = new AccessControlList();
acl.grantPermission(GroupGrantee.AllUsers, Permission.Read);
s3client.putObject(new PutObjectRequest(bucketName, getAPKDownloadFilePathWithFile(fileToUpload.getName()), fileToUpload).withAccessControlList(acl));
SagLogger.logInfo(session, "Finished uploading to S3");
}
catch (Exception e)
{
SagLogger.logException(session, e);
throw new S3Exception(e);
}
}
开发者ID:benetech,项目名称:Secure-App-Generator,代码行数:22,代码来源:AmazonS3Utils.java
示例3: testPut
import com.amazonaws.services.s3.model.GroupGrantee; //导入依赖的package包/类
@Test
public void testPut() {
ModelBucket bucket = getService(ModelBucket.class);
InputStream stream = new ByteArrayInputStream("file content".getBytes());
ArgumentCaptor<PutObjectRequest> requestCaptor = ArgumentCaptor.forClass(PutObjectRequest.class);
PutObjectResult expected = new PutObjectResult();
when(amazonS3Client.putObject(requestCaptor.capture())).thenReturn(expected);
assertEquals(expected, bucket.put("path", stream, 12L));
PutObjectRequest request = requestCaptor.getValue();
assertEquals("model-bucket", request.getBucketName());
assertEquals("path", request.getKey());
assertEquals(stream, request.getInputStream());
assertEquals(12L, request.getMetadata().getContentLength());
List<Grant> grants = request.getAccessControlList().getGrantsAsList();
assertEquals(1, grants.size());
assertEquals(GroupGrantee.AllUsers, grants.get(0).getGrantee());
assertEquals(Permission.Read, grants.get(0).getPermission());
}
开发者ID:coding4people,项目名称:mosquito-report-api,代码行数:27,代码来源:BucketTest.java
示例4: testUpdateBlobXmlAcls
import com.amazonaws.services.s3.model.GroupGrantee; //导入依赖的package包/类
@Test
public void testUpdateBlobXmlAcls() throws Exception {
assumeTrue(!Quirks.NO_BLOB_ACCESS_CONTROL.contains(blobStoreType));
String blobName = "testUpdateBlobXmlAcls-blob";
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(BYTE_SOURCE.size());
client.putObject(containerName, blobName, BYTE_SOURCE.openStream(),
metadata);
AccessControlList acl = client.getObjectAcl(containerName, blobName);
acl.grantPermission(GroupGrantee.AllUsers, Permission.Read);
client.setObjectAcl(containerName, blobName, acl);
assertThat(client.getObjectAcl(containerName, blobName)).isEqualTo(acl);
acl.revokeAllPermissions(GroupGrantee.AllUsers);
client.setObjectAcl(containerName, blobName, acl);
assertThat(client.getObjectAcl(containerName, blobName)).isEqualTo(acl);
acl.grantPermission(GroupGrantee.AllUsers, Permission.Write);
try {
client.setObjectAcl(containerName, blobName, acl);
Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
} catch (AmazonS3Exception e) {
assertThat(e.getErrorCode()).isEqualTo("NotImplemented");
}
}
开发者ID:gaul,项目名称:s3proxy,代码行数:27,代码来源:AwsSdkTest.java
示例5: put
import com.amazonaws.services.s3.model.GroupGrantee; //导入依赖的package包/类
public Object put(String path, InputStream fileInputStream, Long contentLenght) {
if (contentLenght == null || contentLenght <= 0) {
FindContentLengthResult result = findContentLength(fileInputStream);
contentLenght = result.getContentLength();
fileInputStream = result.getFileInputStream();
}
ObjectMetadata meta = new ObjectMetadata();
meta.setContentLength(contentLenght);
AccessControlList acl = new AccessControlList();
acl.grantPermission(GroupGrantee.AllUsers, Permission.Read);
return amazonS3Client.putObject(new PutObjectRequest(getBucketName(), path, fileInputStream, meta).withAccessControlList(acl));
}
开发者ID:coding4people,项目名称:mosquito-report-api,代码行数:16,代码来源:Bucket.java
示例6: testPutWithoutContentLenght
import com.amazonaws.services.s3.model.GroupGrantee; //导入依赖的package包/类
@Test
public void testPutWithoutContentLenght() {
ModelBucket bucket = getService(ModelBucket.class);
InputStream stream = new ByteArrayInputStream("file content".getBytes());
ArgumentCaptor<PutObjectRequest> requestCaptor = ArgumentCaptor.forClass(PutObjectRequest.class);
PutObjectResult expected = new PutObjectResult();
when(amazonS3Client.putObject(requestCaptor.capture())).thenReturn(expected);
assertEquals(expected, bucket.put("path", stream, null));
PutObjectRequest request = requestCaptor.getValue();
Scanner scanner = new Scanner(request.getInputStream());
assertEquals("model-bucket", request.getBucketName());
assertEquals("path", request.getKey());
assertEquals("file content", scanner.useDelimiter("\\A").next());
assertEquals(12L, request.getMetadata().getContentLength());
List<Grant> grants = request.getAccessControlList().getGrantsAsList();
assertEquals(1, grants.size());
assertEquals(GroupGrantee.AllUsers, grants.get(0).getGrantee());
assertEquals(Permission.Read, grants.get(0).getPermission());
scanner.close();
}
开发者ID:coding4people,项目名称:mosquito-report-api,代码行数:30,代码来源:BucketTest.java
示例7: getBucketAcl
import com.amazonaws.services.s3.model.GroupGrantee; //导入依赖的package包/类
@Override
public AccessControlList getBucketAcl(String bucketName) throws AmazonClientException, AmazonServiceException {
throwException(getBucketAclException);
AccessControlList acl = new AccessControlList();
acl.grantPermission(GroupGrantee.AllUsers, Permission.FullControl);
return acl;
}
开发者ID:DemandCube,项目名称:Scribengin,代码行数:8,代码来源:AmazonS3Mock.java
示例8: deploy
import com.amazonaws.services.s3.model.GroupGrantee; //导入依赖的package包/类
public void deploy(AwsKeyPair keyPair, String region, String inputDirectory, final String bucketName,
final String outputBasePath, Proxy proxy) {
final AWSCredentialsProvider credentials = new AWSStaticCredentialsProvider(
new BasicAWSCredentials(keyPair.key, keyPair.secret));
ClientConfiguration cc = Util.createConfiguration(proxy);
final AmazonS3 s3 = AmazonS3ClientBuilder.standard().withCredentials(credentials).withClientConfiguration(cc)
.withRegion(region).build();
if (inputDirectory == null) {
throw new RuntimeException("must specify inputDirectory parameter in configuration");
}
final Path root = new File(inputDirectory).toPath().toAbsolutePath();
try {
Files.walkFileTree(root, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
AccessControlList acl = new AccessControlList();
acl.grantPermission(GroupGrantee.AllUsers, Permission.Read);
String relativePath = root.relativize(file.toAbsolutePath()).toString();
String objectName;
if (outputBasePath != null) {
objectName = outputBasePath + "/" + relativePath;
} else {
objectName = relativePath;
}
log.info("uploading " + file.toFile() + " to " + bucketName + ":" + objectName);
PutObjectRequest req = new PutObjectRequest(bucketName, objectName, file.toFile()) //
.withAccessControlList(acl);
s3.putObject(req);
return FileVisitResult.CONTINUE;
}
});
log.info("uploaded files");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
开发者ID:davidmoten,项目名称:aws-maven-plugin,代码行数:44,代码来源:S3Deployer.java
示例9: convertToXml
import com.amazonaws.services.s3.model.GroupGrantee; //导入依赖的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());
}
}
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:26,代码来源:AclXmlFactory.java
注:本文中的com.amazonaws.services.s3.model.GroupGrantee类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论