use of com.amazonaws.services.s3.model.GroupGrantee in project quickutil by quickutil.
the class AWSS3Util method uploadFile.
/**
* 上传
*
* @param s3Name-S3Name
* @param bt-文件内容
* @param filePath-文件路径
* @param contentType-文件类型
*/
public static String uploadFile(String s3Name, byte[] bt, String filePath, String contentType, GroupGrantee groupGrantee, Permission permission) {
InputStream is = new ByteArrayInputStream(bt);
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(bt.length);
if (contentType != null)
metadata.setContentType(contentType);
AccessControlList acl = new AccessControlList();
acl.grantPermission(groupGrantee, permission);
buildClient(s3Name).putObject(new PutObjectRequest(bucketMap.get(s3Name).get("bucket"), filePath, is, metadata).withAccessControlList(acl));
return bucketMap.get(s3Name).get("endpoint") + "/" + bucketMap.get(s3Name).get("bucket") + "/" + filePath;
}
use of com.amazonaws.services.s3.model.GroupGrantee in project alluxio by Alluxio.
the class S3AUtilsTest method translateAuthenticatedUserWritePermission.
@Test
public void translateAuthenticatedUserWritePermission() {
GroupGrantee authenticatedUsersGrantee = GroupGrantee.AuthenticatedUsers;
mAcl.grantPermission(authenticatedUsersGrantee, Permission.Write);
Assert.assertEquals((short) 0200, S3AUtils.translateBucketAcl(mAcl, ID));
Assert.assertEquals((short) 0200, S3AUtils.translateBucketAcl(mAcl, OTHER_ID));
}
use of com.amazonaws.services.s3.model.GroupGrantee in project alluxio by Alluxio.
the class S3AUtilsTest method translateEveryoneFullPermission.
@Test
public void translateEveryoneFullPermission() {
GroupGrantee allUsersGrantee = GroupGrantee.AllUsers;
mAcl.grantPermission(allUsersGrantee, Permission.FullControl);
Assert.assertEquals((short) 0700, S3AUtils.translateBucketAcl(mAcl, ID));
Assert.assertEquals((short) 0700, S3AUtils.translateBucketAcl(mAcl, OTHER_ID));
}
use of com.amazonaws.services.s3.model.GroupGrantee in project alluxio by Alluxio.
the class S3AUtilsTest method translateAuthenticatedUserReadPermission.
@Test
public void translateAuthenticatedUserReadPermission() {
GroupGrantee authenticatedUsersGrantee = GroupGrantee.AuthenticatedUsers;
mAcl.grantPermission(authenticatedUsersGrantee, Permission.Read);
Assert.assertEquals((short) 0500, S3AUtils.translateBucketAcl(mAcl, ID));
Assert.assertEquals((short) 0500, S3AUtils.translateBucketAcl(mAcl, OTHER_ID));
}
use of com.amazonaws.services.s3.model.GroupGrantee in project alluxio by Alluxio.
the class S3AUtilsTest method translateEveryoneWritePermission.
@Test
public void translateEveryoneWritePermission() {
GroupGrantee allUsersGrantee = GroupGrantee.AllUsers;
mAcl.grantPermission(allUsersGrantee, Permission.Write);
Assert.assertEquals((short) 0200, S3AUtils.translateBucketAcl(mAcl, ID));
Assert.assertEquals((short) 0200, S3AUtils.translateBucketAcl(mAcl, OTHER_ID));
}
Aggregations