本文整理匯總了Java中com.amazonaws.services.s3.model.PutObjectResult.setContentMd5方法的典型用法代碼示例。如果您正苦於以下問題:Java PutObjectResult.setContentMd5方法的具體用法?Java PutObjectResult.setContentMd5怎麽用?Java PutObjectResult.setContentMd5使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.amazonaws.services.s3.model.PutObjectResult
的用法示例。
在下文中一共展示了PutObjectResult.setContentMd5方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: putObject
import com.amazonaws.services.s3.model.PutObjectResult; //導入方法依賴的package包/類
@Override
public PutObjectResult putObject(PutObjectRequest putObjectRequest)
throws AmazonClientException, AmazonServiceException {
String blobName = putObjectRequest.getKey();
DigestInputStream stream = (DigestInputStream) putObjectRequest.getInputStream();
if (blobs.containsKey(blobName)) {
throw new AmazonS3Exception("[" + blobName + "] already exists.");
}
blobs.put(blobName, stream);
// input and output md5 hashes need to match to avoid an exception
String md5 = Base64.encodeAsString(stream.getMessageDigest().digest());
PutObjectResult result = new PutObjectResult();
result.setContentMd5(md5);
return result;
}
示例2: putObject
import com.amazonaws.services.s3.model.PutObjectResult; //導入方法依賴的package包/類
@Override
public PutObjectResult putObject(String bucketName, String key, File file) throws AmazonClientException,
AmazonServiceException {
throwException(putObjectException);
List<String> keys = files.get(bucketName);
if (keys == null) {
throw new AmazonClientException("Bucket do not exist");
}
keys.add(key);
files.put(bucketName, keys);
PutObjectResult result = new PutObjectResult();
try {
result.setContentMd5(new String(Md5Utils.md5AsBase64(file)));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
示例3: buildPutObjectResult
import com.amazonaws.services.s3.model.PutObjectResult; //導入方法依賴的package包/類
private PutObjectResult buildPutObjectResult(FakeS3Object object) {
PutObjectResult result = new PutObjectResult();
result.setETag(object.getETag());
result.setContentMd5(object.getMd5());
return result;
}