当前位置: 首页>>代码示例>>Java>>正文


Java CreateBucketRequest类代码示例

本文整理汇总了Java中com.amazonaws.services.s3.model.CreateBucketRequest的典型用法代码示例。如果您正苦于以下问题:Java CreateBucketRequest类的具体用法?Java CreateBucketRequest怎么用?Java CreateBucketRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CreateBucketRequest类属于com.amazonaws.services.s3.model包,在下文中一共展示了CreateBucketRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addIAMHeaders

import com.amazonaws.services.s3.model.CreateBucketRequest; //导入依赖的package包/类
/**  
 * Add IAM specific headers based on the credentials set & any optional  
 * parameters added to the CreateBucketRequest object  
 *   
 * @param request  
 * @param createBucketRequest  
 * @return Request<CreateBucketRequest>  
 */  
protected Request<CreateBucketRequest> addIAMHeaders(Request<CreateBucketRequest> request, CreateBucketRequest createBucketRequest){  
  
	if ((null != this.awsCredentialsProvider ) && (this.awsCredentialsProvider.getCredentials() instanceof IBMOAuthCredentials)) {  
		if (null != createBucketRequest.getServiceInstanceId()) {  
			request.addHeader(Headers.IBM_SERVICE_INSTANCE_ID, createBucketRequest.getServiceInstanceId());  
		} else {  
 		IBMOAuthCredentials oAuthCreds = (IBMOAuthCredentials)this.awsCredentialsProvider.getCredentials();  
 		if (oAuthCreds.getServiceInstanceId() != null) {  
         	request.addHeader(Headers.IBM_SERVICE_INSTANCE_ID, oAuthCreds.getServiceInstanceId());	  
 		}  
		}  
}  
	  
	return request;  
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:24,代码来源:AmazonS3Client.java

示例2: createBucket

import com.amazonaws.services.s3.model.CreateBucketRequest; //导入依赖的package包/类
/**
 * Create an amazon bucket in the specified region
 * @param bucket - The s3 bucket name
 * @param region - The S3 region the bucket should be created in
 * @param accessList - The access control list settings for the bucket
 */
public void createBucket(final String bucket, 
			final Region region, 
			final CannedAccessControlList cannedACL, 
			final AccessControlList accessList){

	
	final CreateBucketRequest request = new CreateBucketRequest(bucket, region);
	if(cannedACL!=null){
		request.withCannedAcl(cannedACL);
	}
	if(accessList!=null){
		request.withAccessControlList(accessList);	
	}
	this.client.createBucket(request);
}
 
开发者ID:shagwood,项目名称:micro-genie,代码行数:22,代码来源:S3Admin.java

示例3: createBucket

import com.amazonaws.services.s3.model.CreateBucketRequest; //导入依赖的package包/类
@Override
public Bucket createBucket(CreateBucketRequest createBucketRequest) throws AmazonClientException, AmazonServiceException {
    if ("nonExistingBucket".equals(createBucketRequest.getBucketName())) {
        nonExistingBucketCreated = true; 
    }
    
    Bucket bucket = new Bucket();
    bucket.setName(createBucketRequest.getBucketName());
    bucket.setCreationDate(new Date());
    bucket.setOwner(new Owner("c2efc7302b9011ba9a78a92ac5fd1cd47b61790499ab5ddf5a37c31f0638a8fc ", "Christian Mueller"));
    return bucket;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:13,代码来源:AmazonS3ClientMock.java

示例4: testServiceInstanceRuntimeParamTakesPrecedence

import com.amazonaws.services.s3.model.CreateBucketRequest; //导入依赖的package包/类
/**
 * Test Service Instance Id is added to the Request Object and
 * the runtime parameter takes precedence over any set by the
 * CredentialProvider
 * 
 */	
@Test
public void testServiceInstanceRuntimeParamTakesPrecedence() {
	
	String serviceInstanceId = "12345";
	
	CreateBucketRequest request = new CreateBucketRequest("testbucket").withServiceInstanceId(serviceInstanceId);
	Request<CreateBucketRequest> defaultRequest = new DefaultRequest(Constants.S3_SERVICE_DISPLAY_NAME);
	AmazonS3Client s3Client = new AmazonS3Client(new BasicIBMOAuthCredentials(new TokenMangerUtilTest(), "54321"));
	defaultRequest = s3Client.addIAMHeaders(defaultRequest, request);
	
	assertEquals(defaultRequest.getHeaders().get(Headers.IBM_SERVICE_INSTANCE_ID), serviceInstanceId);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:19,代码来源:AmazonS3ClientTest.java

示例5: testServiceInstanceHeaderIsAddedByCredentialProvdier

import com.amazonaws.services.s3.model.CreateBucketRequest; //导入依赖的package包/类
/**
 * Test Service Instance Id is added to the Request Object by 
 * the CredentialProvider
 * 
 */	
@Test
public void testServiceInstanceHeaderIsAddedByCredentialProvdier() {
	
	String serviceInstanceId = "12345";
	
	CreateBucketRequest request = new CreateBucketRequest("testbucket");
	Request<CreateBucketRequest> defaultRequest = new DefaultRequest(Constants.S3_SERVICE_DISPLAY_NAME);
	AmazonS3Client s3Client = new AmazonS3Client(new BasicIBMOAuthCredentials(new TokenMangerUtilTest(), serviceInstanceId));
	defaultRequest = s3Client.addIAMHeaders(defaultRequest, request);
	
	assertEquals(defaultRequest.getHeaders().get(Headers.IBM_SERVICE_INSTANCE_ID), serviceInstanceId);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:18,代码来源:AmazonS3ClientTest.java

示例6: testNoIAMHeadersAreAdded

import com.amazonaws.services.s3.model.CreateBucketRequest; //导入依赖的package包/类
/**
 * Test No IAM Headers are added & no null pointers are thrown
 * 
 */	
@Test
public void testNoIAMHeadersAreAdded() {
			
	CreateBucketRequest request = new CreateBucketRequest("testbucket");
	Request<CreateBucketRequest> defaultRequest = new DefaultRequest(Constants.S3_SERVICE_DISPLAY_NAME);
	AmazonS3Client s3Client = new AmazonS3Client(new BasicAWSCredentials("987654321", "123456789"));
	defaultRequest = s3Client.addIAMHeaders(defaultRequest, request);
	
	assertEquals(defaultRequest.getHeaders().get(Headers.IBM_SERVICE_INSTANCE_ID), null);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:15,代码来源:AmazonS3ClientTest.java

示例7: createBucketIfNotExists

import com.amazonaws.services.s3.model.CreateBucketRequest; //导入依赖的package包/类
/**
 * Creates new bucket if not existing
 *
 * @param bucket Bucket
 * @param region Region
 * @return true on success, false on failure
 */
public static boolean createBucketIfNotExists(String bucket, String region) {

    if (getS3Client().doesBucketExist(bucket)) {
        return false;
    }

    getS3Client().createBucket(new CreateBucketRequest(bucket, region));
    return true;
}
 
开发者ID:lambadaframework,项目名称:lambadaframework,代码行数:17,代码来源:S3.java

示例8: createS3BucketIfNotExist

import com.amazonaws.services.s3.model.CreateBucketRequest; //导入依赖的package包/类
public void createS3BucketIfNotExist(String bucketName, String regionName, boolean isOutputBucket) throws TranscodeException{
    s3client.setRegion(Region.getRegion(Regions.fromName(regionName)));
    try {
        if(!(s3client.doesBucketExist(bucketName)))
        {
        	// Note that CreateBucketRequest does not specify region. So bucket is 
        	// created in the region specified in the client.
        	s3client.createBucket(new CreateBucketRequest(
        			bucketName));
        }
        
        if (isOutputBucket){
        	String policyText = "{"
        			  + "\"Id\": \"1\","
        			  + "\"Version\": \"2012-10-17\","
        			  + "\"Statement\": ["
        			  + "  {"
        			  + "    \"Sid\": \"1\","
        			  + "    \"Action\": ["
        			  + "    \"s3:GetObject\""
        			  + "    ],"
        			  + "  \"Effect\": \"Allow\","
        			  + "  \"Resource\": \"arn:aws:s3:::"+bucketName+"/*\","
        			  + "  \"Principal\": \"*\""
        			  + "  }"
        			  + "]"
        			  + "}";
        	SetBucketPolicyRequest setBucketPolicyRequest = new SetBucketPolicyRequest(bucketName, policyText);
        	s3client.setBucketPolicy(setBucketPolicyRequest);
        }	        
     } catch (AmazonServiceException ase) {
        logger.error("Caught an AmazonServiceException, which " +
        		"means your request made it " +
                "to Amazon S3, but was rejected with an error response" +
                " for some reason.", ase);
        throw new TranscodeException(ase.getMessage());
    } catch (AmazonClientException ace) {
        logger.error("Caught an AmazonClientException, which " +
        		"means the client encountered " +
                "an internal error while trying to " +
                "communicate with S3, " +
                "such as not being able to access the network.", ace);
        throw new TranscodeException(ace.getMessage());
    } catch (IllegalArgumentException ie) {
        logger.error("Couldn't get the region", ie);
    	throw new TranscodeException(ie.getMessage());
    }
}
 
开发者ID:TimShi,项目名称:s3_video,代码行数:49,代码来源:AWSAdapter.java

示例9: createBucket

import com.amazonaws.services.s3.model.CreateBucketRequest; //导入依赖的package包/类
@Override
public Bucket createBucket(final String bucketName, final CannedAccessControlList cannedAcl)
		throws AmazonClientException, AmazonServiceException {
	LOGGER.info("createBucket invoked, bucketName: {} and cannedAccessControlList: {}",bucketName,cannedAcl);
	final CreateBucketRequest createBucketReq = new CreateBucketRequest(bucketName).withCannedAcl(cannedAcl);
	return s3client.createBucket(createBucketReq);
}
 
开发者ID:abhinavmishra14,项目名称:aws-s3-utils,代码行数:8,代码来源:AwsS3IamServiceImpl.java

示例10: createBucket

import com.amazonaws.services.s3.model.CreateBucketRequest; //导入依赖的package包/类
public static void createBucket(AmazonS3 s3client, String bucketName) {
  if(s3client.doesBucketExist(bucketName)) {
    for(S3ObjectSummary s : S3Objects.inBucket(s3client, bucketName)) {
      s3client.deleteObject(bucketName, s.getKey());
    }
    s3client.deleteBucket(bucketName);
  }
  Assert.assertFalse(s3client.doesBucketExist(bucketName));
  // Note that CreateBucketRequest does not specify region. So bucket is
  // bucketName
  s3client.createBucket(new CreateBucketRequest(bucketName));
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:13,代码来源:TestUtil.java

示例11: createBucket

import com.amazonaws.services.s3.model.CreateBucketRequest; //导入依赖的package包/类
@Override
public Optional<Boolean> createBucket(Bucket bucket) {
  try {
    CreateBucketRequest bucketRequest = new CreateBucketRequest(bucket.getBucketName(), Region.US_West);
    bucketRequest.withCannedAcl(CannedAccessControlList.PublicRead);
    s3Client.createBucket(bucketRequest);

    return TRUE;
  } catch (Exception e) {
    log.error("Error creating bucket", e);
    return FALSE;
  }
}
 
开发者ID:PLOS,项目名称:content-repo,代码行数:14,代码来源:S3StoreService.java

示例12: main

import com.amazonaws.services.s3.model.CreateBucketRequest; //导入依赖的package包/类
public static void main(String[] args) {

	if (!S3.doesBucketExist(S3_BUCKET_NAME)) {
		S3.createBucket(new CreateBucketRequest(S3_BUCKET_NAME));
	}
	System.out.println("Using Amazon S3 Bucket: " + S3_BUCKET_NAME);
}
 
开发者ID:snehangshuk,项目名称:aws,代码行数:8,代码来源:AWSResources.java

示例13: main

import com.amazonaws.services.s3.model.CreateBucketRequest; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	CreateBucketRequest createBucketRequest = new CreateBucketRequest(AWSResources.S3_BUCKET_NAME);
	try {
	AWSResources.S3.createBucket(createBucketRequest);
	System.out.println("Bucket Created...");
	}
	catch (AmazonS3Exception ex){
		if(!ex.getErrorCode().equals(createBucketRequest)) {
			throw ex;
		}
	}
}
 
开发者ID:snehangshuk,项目名称:aws,代码行数:13,代码来源:CreateBucket.java

示例14: createBucket

import com.amazonaws.services.s3.model.CreateBucketRequest; //导入依赖的package包/类
@Override
public Bucket createBucket(CreateBucketRequest createBucketRequest) throws AmazonClientException, AmazonServiceException {
    return delegate.createBucket(createBucketRequest);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AmazonS3Wrapper.java

示例15: createBucket

import com.amazonaws.services.s3.model.CreateBucketRequest; //导入依赖的package包/类
@Override
public Bucket createBucket(String bucketName)
        throws SdkClientException, AmazonServiceException {
    return createBucket(new CreateBucketRequest(bucketName));
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:6,代码来源:AmazonS3Client.java


注:本文中的com.amazonaws.services.s3.model.CreateBucketRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。