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


Java CopyObjectRequest.setCannedAccessControlList方法代码示例

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


在下文中一共展示了CopyObjectRequest.setCannedAccessControlList方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyFile

import com.amazonaws.services.s3.model.CopyObjectRequest; //导入方法依赖的package包/类
private void copyFile(String srcKey, String dstKey) throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("copyFile " + srcKey + " -> " + dstKey);
  }

  ObjectMetadata srcom = s3.getObjectMetadata(bucket, srcKey);
  final ObjectMetadata dstom = srcom.clone();
  if (StringUtils.isNotBlank(serverSideEncryptionAlgorithm)) {
    dstom.setServerSideEncryption(serverSideEncryptionAlgorithm);
  }
  CopyObjectRequest copyObjectRequest = new CopyObjectRequest(bucket, srcKey, bucket, dstKey);
  copyObjectRequest.setCannedAccessControlList(cannedACL);
  copyObjectRequest.setNewObjectMetadata(dstom);

  ProgressListener progressListener = new ProgressListener() {
    public void progressChanged(ProgressEvent progressEvent) {
      switch (progressEvent.getEventCode()) {
        case ProgressEvent.PART_COMPLETED_EVENT_CODE:
          statistics.incrementWriteOps(1);
          break;
        default:
          break;
      }
    }
  };

  Copy copy = transfers.copy(copyObjectRequest);
  copy.addProgressListener(progressListener);
  try {
    copy.waitForCopyResult();
    statistics.incrementWriteOps(1);
  } catch (InterruptedException e) {
    throw new IOException("Got interrupted, cancelling");
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:36,代码来源:S3AFileSystem.java

示例2: copyFile

import com.amazonaws.services.s3.model.CopyObjectRequest; //导入方法依赖的package包/类
private void copyFile(String srcKey, String dstKey) throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("copyFile " + srcKey + " -> " + dstKey);
  }

  ObjectMetadata srcom = s3.getObjectMetadata(bucket, srcKey);
  final ObjectMetadata dstom = srcom.clone();
  if (StringUtils.isNotBlank(serverSideEncryptionAlgorithm)) {
    dstom.setSSEAlgorithm(serverSideEncryptionAlgorithm);
  }
  CopyObjectRequest copyObjectRequest = new CopyObjectRequest(bucket, srcKey, bucket, dstKey);
  copyObjectRequest.setCannedAccessControlList(cannedACL);
  copyObjectRequest.setNewObjectMetadata(dstom);

  ProgressListener progressListener = new ProgressListener() {
    public void progressChanged(ProgressEvent progressEvent) {
      switch (progressEvent.getEventType()) {
        case TRANSFER_PART_COMPLETED_EVENT:
          statistics.incrementWriteOps(1);
          break;
        default:
          break;
      }
    }
  };

  Copy copy = transfers.copy(copyObjectRequest);
  copy.addProgressListener(progressListener);
  try {
    copy.waitForCopyResult();
    statistics.incrementWriteOps(1);
  } catch (InterruptedException e) {
    throw new IOException("Got interrupted, cancelling");
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:36,代码来源:S3AFileSystem.java

示例3: copyFile

import com.amazonaws.services.s3.model.CopyObjectRequest; //导入方法依赖的package包/类
private void copyFile(String srcKey, String dstKey) throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("copyFile " + srcKey + " -> " + dstKey);
  }

  ObjectMetadata srcom = s3.getObjectMetadata(bucket, srcKey);
  final ObjectMetadata dstom = srcom.clone();
  if (StringUtils.isNotBlank(serverSideEncryptionAlgorithm)) {
    dstom.setServerSideEncryption(serverSideEncryptionAlgorithm);
  }
  CopyObjectRequest copyObjectRequest = new CopyObjectRequest(bucket, srcKey, bucket, dstKey);
  copyObjectRequest.setCannedAccessControlList(cannedACL);
  copyObjectRequest.setNewObjectMetadata(dstom);

  ProgressListener progressListener = new ProgressListener() {
    public void progressChanged(ProgressEvent progressEvent) {
      switch (progressEvent.getEventCode()) {
        case ProgressEvent.PART_COMPLETED_EVENT_CODE:
          statistics.incrementWriteOps(1);
          break;
      }
    }
  };

  Copy copy = transfers.copy(copyObjectRequest);
  copy.addProgressListener(progressListener);
  try {
    copy.waitForCopyResult();
    statistics.incrementWriteOps(1);
  } catch (InterruptedException e) {
    throw new IOException("Got interrupted, cancelling");
  }
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:34,代码来源:S3AFileSystem.java

示例4: copyUpdatedBookingPageToS3

import com.amazonaws.services.s3.model.CopyObjectRequest; //导入方法依赖的package包/类
private void copyUpdatedBookingPageToS3(String pageBaseName, String page, String uidSuffix,
    boolean usePrefix) throws Exception {

  logger.log("About to copy booking page to S3");

  String pageBaseNameWithPrefix = usePrefix ? "NoScript/" + pageBaseName : pageBaseName;
  try {
    logger.log("Uploading booking page to S3 bucket: " + websiteBucketName
        + "s3websitebucketname" + " and key: " + pageBaseNameWithPrefix + uidSuffix + ".html");
    byte[] pageAsGzippedBytes = FileUtils.gzip(page.getBytes(StandardCharsets.UTF_8), logger);

    ByteArrayInputStream pageAsStream = new ByteArrayInputStream(pageAsGzippedBytes);
    ObjectMetadata metadata = new ObjectMetadata();
    metadata.setContentLength(pageAsGzippedBytes.length);
    metadata.setContentEncoding("gzip");
    metadata.setContentType("text/html");
    // Direct caches not to satisfy future requests with this data without
    // revalidation.
    metadata.setCacheControl("no-cache, must-revalidate");
    PutObjectRequest putObjectRequest = new PutObjectRequest(websiteBucketName,
        pageBaseNameWithPrefix + uidSuffix + ".html", pageAsStream, metadata);
    // Page must be public so it can be served from the website
    putObjectRequest.setCannedAcl(CannedAccessControlList.PublicRead);
    IS3TransferManager transferManager = getS3TransferManager();
    TransferUtils.waitForS3Transfer(transferManager.upload(putObjectRequest), logger);
    logger.log("Uploaded booking page to S3 bucket");

    if (uidSuffix.equals("")) {
      // Nothing to copy - so return
      logger.log("UidSuffix is empty - so not creating duplicate page");
      return;
    }

    // N.B. We copy from hashed key to non-hashed (and not vice versa)
    // to ensure consistency
    logger.log("Copying booking page in S3 bucket: " + websiteBucketName + " and key: "
        + pageBaseNameWithPrefix + ".html");
    CopyObjectRequest copyObjectRequest = new CopyObjectRequest(websiteBucketName,
        pageBaseNameWithPrefix + uidSuffix + ".html", websiteBucketName, pageBaseNameWithPrefix
            + ".html");
    copyObjectRequest.setCannedAccessControlList(CannedAccessControlList.PublicRead);
    // N.B. Copied object will get same metadata as the source (e.g. the
    // cache-control header etc.)
    TransferUtils.waitForS3Transfer(transferManager.copy(copyObjectRequest), logger);
    logger.log("Copied booking page successfully in S3");
  } catch (AmazonServiceException ase) {
    ExceptionUtils.logAmazonServiceException(ase, logger);
    throw new Exception("Exception caught while copying booking page to S3");
  } catch (AmazonClientException ace) {
    ExceptionUtils.logAmazonClientException(ace, logger);
    throw new Exception("Exception caught while copying booking page to S3");
  } catch (InterruptedException e) {
    logger.log("Caught interrupted exception: ");
    logger.log("Error Message: " + e.getMessage());
    throw new Exception("Exception caught while copying booking page to S3");
  }
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:58,代码来源:PageManager.java

示例5: execute

import com.amazonaws.services.s3.model.CopyObjectRequest; //导入方法依赖的package包/类
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException{

AmazonKey amazonKey	= getAmazonKey(_session, argStruct);
AmazonS3 s3Client		= getAmazonS3(amazonKey);

	String srcbucket		= getNamedStringParam(argStruct, "srcbucket", null );
	String srckey				= getNamedStringParam(argStruct, "srckey", null );
	String srcaes256key	= getNamedStringParam(argStruct, "srcaes256key", null );
	
	String destbucket					= getNamedStringParam(argStruct, "destbucket", null );
	String deskey							= getNamedStringParam(argStruct, "destkey", null );
	String destaes256key			= getNamedStringParam(argStruct, "destaes256key", null );
	String deststorageclass		= getNamedStringParam(argStruct, "deststorageclass", null );
	String destacl						= getNamedStringParam(argStruct, "destacl", null );
	
if ( srckey != null && srckey.charAt( 0 ) == '/' )
	srckey	= srckey.substring(1);

if ( deskey != null && deskey.charAt( 0 ) == '/' )
	deskey	= deskey.substring(1);
	
	CopyObjectRequest cor = new CopyObjectRequest(srcbucket, srckey, destbucket, deskey);
	
	if ( srcaes256key != null && !srcaes256key.isEmpty() )
		cor.setSourceSSECustomerKey( new SSECustomerKey(srcaes256key) );

	if ( destaes256key != null && !destaes256key.isEmpty() )
		cor.setDestinationSSECustomerKey( new SSECustomerKey(destaes256key) );
	
	if ( deststorageclass != null && !deststorageclass.isEmpty() )
		cor.setStorageClass( amazonKey.getAmazonStorageClass(deststorageclass) );
	
	if ( destacl != null && !destacl.isEmpty() )
		cor.setCannedAccessControlList( amazonKey.getAmazonCannedAcl(destacl) );
	
try {
	s3Client.copyObject(cor);
	return cfBooleanData.TRUE;
} catch (Exception e) {
	throwException(_session, "AmazonS3: " + e.getMessage() );
	return cfBooleanData.FALSE;
}
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:44,代码来源:Copy.java


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