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


Java PutObjectRequest.setMetadata方法代码示例

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


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

示例1: uploadFile

import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
/**
 * Upload a file which is in the assets bucket.
 * 
 * @param fileName File name
 * @param file File
 * @param contentType Content type for file
 * @return
 */
public static boolean uploadFile(String fileName, File file, String contentType) {
    try {
        if (S3Module.amazonS3 != null) {
            String bucket = S3Module.s3Bucket;
            ObjectMetadata metaData = new ObjectMetadata();
            if (contentType != null) {
                metaData.setContentType(contentType);
            }
            PutObjectRequest putObj = new PutObjectRequest(bucket,
                    fileName, file);
            putObj.setMetadata(metaData);
            putObj.withCannedAcl(CannedAccessControlList.PublicRead);
            S3Module.amazonS3.putObject(putObj);
            return true;
        } else {
            Logger.error("Could not save because amazonS3 was null");
            return false;
        }
    } catch (Exception e) {
        Logger.error("S3 Upload -" + e.getMessage());
        return false;
    }
}
 
开发者ID:webinerds,项目名称:s3-proxy-chunk-upload,代码行数:32,代码来源:AssetsS3.java

示例2: putObjectUsingMetadata

import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
private PutObjectResult putObjectUsingMetadata(PutObjectRequest req) {
    ContentCryptoMaterial cekMaterial = createContentCryptoMaterial(req);
    // Wraps the object data with a cipher input stream
    final File fileOrig = req.getFile();
    final InputStream isOrig = req.getInputStream();
    PutObjectRequest wrappedReq = wrapWithCipher(req, cekMaterial);
    // Update the metadata
    req.setMetadata(updateMetadataWithContentCryptoMaterial(
            req.getMetadata(), req.getFile(), cekMaterial));
    // Put the encrypted object into S3
    try {
        return s3.putObject(wrappedReq);
    } finally {
        cleanupDataSource(req, fileOrig, isOrig, wrappedReq.getInputStream(), log);
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:17,代码来源:S3CryptoModuleBase.java

示例3: uploadFile

import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
/**
 * Use UploadFile.BucketName
 * @param keyName
 * @param filePathToUpload
 * @param BUCKET_NAME
 */
public static void uploadFile(String keyName,File fileToUpload,String BUCKET_NAME,String contentType) {
	
	

       AmazonS3 s3Client = s3client(); 

       System.out.println(s3Client);
       
       try {
       	System.out.println("Uploading a new object to S3 from a file\n");
           File file = fileToUpload;
           PutObjectRequest objectToPut = new PutObjectRequest(BUCKET_NAME, keyName, file);
           ObjectMetadata meta = new ObjectMetadata();
           meta.setContentType(contentType);
           objectToPut.setMetadata(meta);
           s3Client.putObject(objectToPut);

        } catch (AmazonServiceException ase) {
           System.out.println("Caught an AmazonServiceException, which " +
           		"means your request made it " +
                   "to Amazon S3, but was rejected with an error response" +
                   " for some reason.");
           System.out.println("Error Message:    " + ase.getMessage());
           System.out.println("HTTP Status Code: " + ase.getStatusCode());
           System.out.println("AWS Error Code:   " + ase.getErrorCode());
           System.out.println("Error Type:       " + ase.getErrorType());
           System.out.println("Request ID:       " + ase.getRequestId());
       } catch (AmazonClientException ace) {
           System.out.println("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.");
           System.out.println("Error Message: " + ace.getMessage());
       }  

	
	
}
 
开发者ID:shalomweiss,项目名称:mm-system-2017,代码行数:46,代码来源:ClientUploadFile.java

示例4: uploadSourceToS3

import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
public UploadToS3Output uploadSourceToS3(TaskListener listener, FilePath workspace) throws Exception {
    Validation.checkS3SourceUploaderConfig(workspace);

    String zipFileName = this.s3InputKey;
    String sourceFilePath = workspace.getRemote();
    String zipFilePath = sourceFilePath.substring(0, sourceFilePath.lastIndexOf(File.separator)+1) + UUID.randomUUID().toString() + "-" + zipFileName;
    FilePath jenkinsZipFile = new FilePath(workspace, zipFilePath);
    ZipOutputStream out = new ZipOutputStream(jenkinsZipFile.write());

    try {
        zipSource(workspace, sourceFilePath, out, sourceFilePath);
    } finally {
        out.close();
    }

    // Add MD5 checksum as S3 Object metadata
    String zipFileMD5 = new String(org.apache.commons.codec.binary.Base64.encodeBase64(DigestUtils.md5(jenkinsZipFile.read())), "UTF-8");;
    ObjectMetadata objectMetadata = new ObjectMetadata();
    objectMetadata.setContentMD5(zipFileMD5);
    objectMetadata.setContentLength(jenkinsZipFile.length());
    if(!sseAlgorithm.isEmpty()) {
        objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
    }

    PutObjectRequest putObjectRequest = new PutObjectRequest(s3InputBucket, s3InputKey, jenkinsZipFile.read(), objectMetadata);
    putObjectRequest.setMetadata(objectMetadata);

    LoggingHelper.log(listener, "Uploading code to S3 at location " + putObjectRequest.getBucketName() + "/" + putObjectRequest.getKey() + ". MD5 checksum is " + zipFileMD5);
    PutObjectResult putObjectResult = s3Client.putObject(putObjectRequest);

    jenkinsZipFile.delete();

    return new UploadToS3Output(putObjectRequest.getBucketName() + "/" + putObjectRequest.getKey(), putObjectResult.getVersionId());
}
 
开发者ID:awslabs,项目名称:aws-codebuild-jenkins-plugin,代码行数:35,代码来源:S3DataManager.java

示例5: save

import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
@Override
public void save(Note note, AuthenticationInfo subject) throws IOException {
  String json = note.toJson();
  String key = user + "/" + "notebook" + "/" + note.getId() + "/" + "note.json";

  File file = File.createTempFile("note", "json");
  try {
    Writer writer = new OutputStreamWriter(new FileOutputStream(file));
    writer.write(json);
    writer.close();

    PutObjectRequest putRequest = new PutObjectRequest(bucketName, key, file);

    if (useServerSideEncryption) {
      // Request server-side encryption.
      ObjectMetadata objectMetadata = new ObjectMetadata();
      objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
      putRequest.setMetadata(objectMetadata);
    }

    s3client.putObject(putRequest);
  }
  catch (AmazonClientException ace) {
    throw new IOException("Unable to store note in S3: " + ace, ace);
  }
  finally {
    FileUtils.deleteQuietly(file);
  }
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:30,代码来源:S3NotebookRepo.java

示例6: close

import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
@Override
public synchronized void close() throws IOException {
  if (closed) {
    return;
  }

  backupStream.close();
  if (LOG.isDebugEnabled()) {
    LOG.debug("OutputStream for key '" + key + "' closed. Now beginning upload");
    LOG.debug("Minimum upload part size: " + partSize + " threshold " + partSizeThreshold);
  }


  try {
    final ObjectMetadata om = new ObjectMetadata();
    if (StringUtils.isNotBlank(serverSideEncryptionAlgorithm)) {
      om.setServerSideEncryption(serverSideEncryptionAlgorithm);
    }
    PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, key, backupFile);
    putObjectRequest.setCannedAcl(cannedACL);
    putObjectRequest.setMetadata(om);

    Upload upload = transfers.upload(putObjectRequest);

    ProgressableProgressListener listener = 
      new ProgressableProgressListener(upload, progress, statistics);
    upload.addProgressListener(listener);

    upload.waitForUploadResult();

    long delta = upload.getProgress().getBytesTransferred() - listener.getLastBytesTransferred();
    if (statistics != null && delta != 0) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("S3A write delta changed after finished: " + delta + " bytes");
      }
      statistics.incrementBytesWritten(delta);
    }

    // This will delete unnecessary fake parent directories
    fs.finishedWrite(key);
  } catch (InterruptedException e) {
    throw new IOException(e);
  } finally {
    if (!backupFile.delete()) {
      LOG.warn("Could not delete temporary s3a file: {}", backupFile);
    }
    super.close();
    closed = true;
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("OutputStream for key '" + key + "' upload complete");
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:54,代码来源:S3AOutputStream.java

示例7: copyFromLocalFile

import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
/**
 * The src file is on the local disk.  Add it to FS at
 * the given dst name.
 *
 * This version doesn't need to create a temporary file to calculate the md5.
 * Sadly this doesn't seem to be used by the shell cp :(
 *
 * delSrc indicates if the source should be removed
 * @param delSrc whether to delete the src
 * @param overwrite whether to overwrite an existing file
 * @param src path
 * @param dst path
 */
@Override
public void copyFromLocalFile(boolean delSrc, boolean overwrite, Path src, 
  Path dst) throws IOException {
  String key = pathToKey(dst);

  if (!overwrite && exists(dst)) {
    throw new IOException(dst + " already exists");
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("Copying local file from " + src + " to " + dst);
  }

  // Since we have a local file, we don't need to stream into a temporary file
  LocalFileSystem local = getLocal(getConf());
  File srcfile = local.pathToFile(src);

  final ObjectMetadata om = new ObjectMetadata();
  if (StringUtils.isNotBlank(serverSideEncryptionAlgorithm)) {
    om.setServerSideEncryption(serverSideEncryptionAlgorithm);
  }
  PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, key, srcfile);
  putObjectRequest.setCannedAcl(cannedACL);
  putObjectRequest.setMetadata(om);

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

  Upload up = transfers.upload(putObjectRequest);
  up.addProgressListener(progressListener);
  try {
    up.waitForUploadResult();
    statistics.incrementWriteOps(1);
  } catch (InterruptedException e) {
    throw new IOException("Got interrupted, cancelling");
  }

  // This will delete unnecessary fake parent directories
  finishedWrite(key);

  if (delSrc) {
    local.delete(src, false);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:66,代码来源:S3AFileSystem.java

示例8: close

import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
@Override
public synchronized void close() throws IOException {
  if (closed) {
    return;
  }

  backupStream.close();
  if (LOG.isDebugEnabled()) {
    LOG.debug("OutputStream for key '" + key + "' closed. Now beginning upload");
    LOG.debug("Minimum upload part size: " + partSize + " threshold " + partSizeThreshold);
  }


  try {
    final ObjectMetadata om = new ObjectMetadata();
    if (StringUtils.isNotBlank(serverSideEncryptionAlgorithm)) {
      om.setSSEAlgorithm(serverSideEncryptionAlgorithm);
    }
    PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, key, backupFile);
    putObjectRequest.setCannedAcl(cannedACL);
    putObjectRequest.setMetadata(om);

    Upload upload = transfers.upload(putObjectRequest);

    ProgressableProgressListener listener = 
      new ProgressableProgressListener(upload, progress, statistics);
    upload.addProgressListener(listener);

    upload.waitForUploadResult();

    long delta = upload.getProgress().getBytesTransferred() - listener.getLastBytesTransferred();
    if (statistics != null && delta != 0) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("S3A write delta changed after finished: " + delta + " bytes");
      }
      statistics.incrementBytesWritten(delta);
    }

    // This will delete unnecessary fake parent directories
    fs.finishedWrite(key);
  } catch (InterruptedException e) {
    throw new IOException(e);
  } finally {
    if (!backupFile.delete()) {
      LOG.warn("Could not delete temporary s3a file: {}", backupFile);
    }
    super.close();
    closed = true;
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("OutputStream for key '" + key + "' upload complete");
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:54,代码来源:S3AOutputStream.java

示例9: copyFromLocalFile

import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
/**
 * The src file is on the local disk.  Add it to FS at
 * the given dst name.
 *
 * This version doesn't need to create a temporary file to calculate the md5.
 * Sadly this doesn't seem to be used by the shell cp :(
 *
 * delSrc indicates if the source should be removed
 * @param delSrc whether to delete the src
 * @param overwrite whether to overwrite an existing file
 * @param src path
 * @param dst path
 */
@Override
public void copyFromLocalFile(boolean delSrc, boolean overwrite, Path src, 
  Path dst) throws IOException {
  String key = pathToKey(dst);

  if (!overwrite && exists(dst)) {
    throw new IOException(dst + " already exists");
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("Copying local file from " + src + " to " + dst);
  }

  // Since we have a local file, we don't need to stream into a temporary file
  LocalFileSystem local = getLocal(getConf());
  File srcfile = local.pathToFile(src);

  final ObjectMetadata om = new ObjectMetadata();
  if (StringUtils.isNotBlank(serverSideEncryptionAlgorithm)) {
    om.setSSEAlgorithm(serverSideEncryptionAlgorithm);
  }
  PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, key, srcfile);
  putObjectRequest.setCannedAcl(cannedACL);
  putObjectRequest.setMetadata(om);

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

  Upload up = transfers.upload(putObjectRequest);
  up.addProgressListener(progressListener);
  try {
    up.waitForUploadResult();
    statistics.incrementWriteOps(1);
  } catch (InterruptedException e) {
    throw new IOException("Got interrupted, cancelling");
  }

  // This will delete unnecessary fake parent directories
  finishedWrite(key);

  if (delSrc) {
    local.delete(src, false);
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:66,代码来源:S3AFileSystem.java

示例10: putObject

import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
/**
 * Upload the current block as a single PUT request; if the buffer is empty a
 * 0-byte PUT will be invoked, as it is needed to create an entry at the far
 * end.
 *
 * @throws IOException any problem
 */
private void putObject() throws IOException {
  LOG.debug("Executing regular upload for {}", writeOperationHelper);

  final COSDataBlocks.DataBlock block = getActiveBlock();
  int size = block.dataSize();
  final COSDataBlocks.BlockUploadData uploadData = block.startUpload();
  final PutObjectRequest putObjectRequest = uploadData.hasFile()
      ? writeOperationHelper.newPutRequest(uploadData.getFile())
      : writeOperationHelper.newPutRequest(uploadData.getUploadStream(), size);

  final ObjectMetadata om = new ObjectMetadata();
  om.setUserMetadata(mMetadata);
  if (contentType != null && !contentType.isEmpty()) {
    om.setContentType(contentType);
  } else {
    om.setContentType("application/octet-stream");
  }
  putObjectRequest.setMetadata(om);
  ListenableFuture<PutObjectResult> putObjectResult =
      executorService.submit(new Callable<PutObjectResult>() {
        @Override
        public PutObjectResult call() throws Exception {
          PutObjectResult result;
          try {
            // the putObject call automatically closes the input
            // stream afterwards.
            result = writeOperationHelper.putObject(putObjectRequest);
          } finally {
            closeAll(LOG, uploadData, block);
          }
          return result;
        }
      });
  clearActiveBlock();
  // wait for completion
  try {
    putObjectResult.get();
  } catch (InterruptedException ie) {
    LOG.warn("Interrupted object upload", ie);
    Thread.currentThread().interrupt();
  } catch (ExecutionException ee) {
    throw extractException("regular upload", key, ee);
  }
}
 
开发者ID:SparkTC,项目名称:stocator,代码行数:52,代码来源:COSBlockOutputStream.java

示例11: copyFromLocalFile

import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
/**
 * The src file is on the local disk.  Add it to FS at
 * the given dst name.
 *
 * This version doesn't need to create a temporary file to calculate the md5.
 * Sadly this doesn't seem to be used by the shell cp :(
 *
 * delSrc indicates if the source should be removed
 * @param delSrc whether to delete the src
 * @param overwrite whether to overwrite an existing file
 * @param src path
 * @param dst path
 */
@Override
public void copyFromLocalFile(boolean delSrc, boolean overwrite, Path src, 
  Path dst) throws IOException {
  String key = pathToKey(dst);

  if (!overwrite && exists(dst)) {
    throw new IOException(dst + " already exists");
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("Copying local file from " + src + " to " + dst);
  }

  // Since we have a local file, we don't need to stream into a temporary file
  LocalFileSystem local = getLocal(getConf());
  File srcfile = local.pathToFile(src);

  final ObjectMetadata om = new ObjectMetadata();
  if (StringUtils.isNotBlank(serverSideEncryptionAlgorithm)) {
    om.setServerSideEncryption(serverSideEncryptionAlgorithm);
  }
  PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, key, srcfile);
  putObjectRequest.setCannedAcl(cannedACL);
  putObjectRequest.setMetadata(om);

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

  Upload up = transfers.upload(putObjectRequest);
  up.addProgressListener(progressListener);
  try {
    up.waitForUploadResult();
    statistics.incrementWriteOps(1);
  } catch (InterruptedException e) {
    throw new IOException("Got interrupted, cancelling");
  }

  // This will delete unnecessary fake parent directories
  finishedWrite(key);

  if (delSrc) {
    local.delete(src, false);
  }
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:64,代码来源:S3AFileSystem.java

示例12: uploadFileList

import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
@Override
public MultipleFileUpload uploadFileList(String bucketName, String virtualDirectoryKeyPrefix, File directory, List<File> files,
    ObjectMetadataProvider metadataProvider, TransferManager transferManager)
{
    LOGGER.debug(
        "uploadFileList(): bucketName = " + bucketName + ", virtualDirectoryKeyPrefix = " + virtualDirectoryKeyPrefix + ", directory = " + directory +
            ", files = " + files);

    String directoryPath = directory.getAbsolutePath();

    long totalFileLength = 0;
    List<Upload> subTransfers = new ArrayList<>();
    for (File file : files)
    {
        // Get path to file relative to the specified directory
        String relativeFilePath = file.getAbsolutePath().substring(directoryPath.length());

        // Replace any backslashes (i.e. Windows separator) with a forward slash.
        relativeFilePath = relativeFilePath.replace("\\", "/");

        // Remove any leading slashes
        relativeFilePath = relativeFilePath.replaceAll("^/+", "");

        long fileLength = file.length();

        // Remove any trailing slashes
        virtualDirectoryKeyPrefix = virtualDirectoryKeyPrefix.replaceAll("/+$", "");

        String s3ObjectKey = virtualDirectoryKeyPrefix + "/" + relativeFilePath;
        totalFileLength += fileLength;

        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, s3ObjectKey, file);

        ObjectMetadata objectMetadata = new ObjectMetadata();
        metadataProvider.provideObjectMetadata(null, objectMetadata);
        putObjectRequest.setMetadata(objectMetadata);

        putObject(putObjectRequest, transferManager.getAmazonS3Client());

        subTransfers.add(new UploadImpl(null, null, null, null));
    }

    TransferProgress progress = new TransferProgress();
    progress.setTotalBytesToTransfer(totalFileLength);
    progress.updateProgress(totalFileLength);

    MultipleFileUploadImpl multipleFileUpload = new MultipleFileUploadImpl(null, progress, null, virtualDirectoryKeyPrefix, bucketName, subTransfers);
    multipleFileUpload.setState(TransferState.Completed);
    return multipleFileUpload;
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:51,代码来源:MockS3OperationsImpl.java

示例13: writeFile

import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
private void writeFile( AmazonKey amazonKey, String bucket, String key, Map<String, String> metadata, StorageClass storage, String localpath, int retry, int retryseconds, boolean deletefile, boolean background, String callback, String callbackdata, String appname, String acl, String aes256key, Map<String, String> customheaders ) throws Exception {
	File localFile = new File( localpath );
	if ( !localFile.isFile() )
		throw new Exception( "The file specified does not exist: " + localpath );

	// Push this to the background loader to handle and return immediately
	if ( background ) {
		BackgroundUploader.acceptFile( amazonKey, bucket, key, metadata, storage, localpath, retry, retryseconds, deletefile, callback, callbackdata, appname, acl, aes256key, customheaders );
		return;
	}


	// Setup the object data
	ObjectMetadata omd = new ObjectMetadata();
	if ( metadata != null )
		omd.setUserMetadata( metadata );

	AmazonS3 s3Client = getAmazonS3( amazonKey );

	// Let us run around the number of attempts
	int attempts = 0;
	while ( attempts < retry ) {
		try {

			PutObjectRequest por = new PutObjectRequest( bucket, key, localFile );
			por.setMetadata( omd );
			por.setStorageClass( storage );

			if ( acl != null && !acl.isEmpty() )
				por.setCannedAcl( amazonKey.getAmazonCannedAcl( acl ) );

			if ( aes256key != null && !aes256key.isEmpty() )
				por.setSSECustomerKey( new SSECustomerKey( aes256key ) );

			if ( customheaders != null && !customheaders.isEmpty() ) {
				Iterator<String> it = customheaders.keySet().iterator();
				while ( it.hasNext() ) {
					String k = it.next();
					por.putCustomRequestHeader( k, customheaders.get( k ) );
				}
			}

			s3Client.putObject( por );
			break;

		} catch ( Exception e ) {
			cfEngine.log( "Failed: AmazonS3Write(bucket=" + bucket + "key=" + key + "; file=" + localFile + "; attempt=" + ( attempts + 1 ) + "; exception=" + e.getMessage() + ")" );
			attempts++;

			if ( attempts == retry )
				throw e;
			else
				Thread.sleep( retryseconds * 1000 );
		}
	}


	// delete the file now that it is a success
	if ( deletefile )
		localFile.delete();
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:62,代码来源:Write.java

示例14: newPutObjectRequest

import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
/**
 * Create a putObject request.
 * Adds the ACL and metadata
 * @param key key of object
 * @param metadata metadata header
 * @param srcfile source file
 * @return the request
 */
public PutObjectRequest newPutObjectRequest(String key,
    ObjectMetadata metadata, File srcfile) {
  PutObjectRequest putObjectRequest = new PutObjectRequest(mBucket, key,
      srcfile);
  putObjectRequest.setMetadata(metadata);
  return putObjectRequest;
}
 
开发者ID:SparkTC,项目名称:stocator,代码行数:16,代码来源:COSAPIClient.java


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