本文整理汇总了Java中com.amazonaws.services.s3.model.PutObjectRequest.getFile方法的典型用法代码示例。如果您正苦于以下问题:Java PutObjectRequest.getFile方法的具体用法?Java PutObjectRequest.getFile怎么用?Java PutObjectRequest.getFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.s3.model.PutObjectRequest
的用法示例。
在下文中一共展示了PutObjectRequest.getFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: putObject
import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
@SuppressWarnings("resource")
@Override
public PutObjectResult putObject(PutObjectRequest putObjectRequest) throws AmazonClientException, AmazonServiceException {
putObjectRequests.add(putObjectRequest);
S3Object s3Object = new S3Object();
s3Object.setBucketName(putObjectRequest.getBucketName());
s3Object.setKey(putObjectRequest.getKey());
if (putObjectRequest.getFile() != null) {
try {
s3Object.setObjectContent(new FileInputStream(putObjectRequest.getFile()));
} catch (FileNotFoundException e) {
throw new AmazonServiceException("Cannot store the file object.", e);
}
} else {
s3Object.setObjectContent(putObjectRequest.getInputStream());
}
objects.add(s3Object);
PutObjectResult putObjectResult = new PutObjectResult();
putObjectResult.setETag("3a5c8b1ad448bca04584ecb55b836264");
return putObjectResult;
}
示例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);
}
}
示例3: putObjectUsingInstructionFile
import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
/**
* Puts an encrypted object into S3, and puts an instruction file into S3.
* Encryption info is stored in the instruction file.
*
* @param putObjectRequest
* The request object containing all the parameters to upload a
* new object to Amazon S3.
* @return A {@link PutObjectResult} object containing the information
* returned by Amazon S3 for the new, created object.
*/
private PutObjectResult putObjectUsingInstructionFile(
PutObjectRequest putObjectRequest) {
final File fileOrig = putObjectRequest.getFile();
final InputStream isOrig = putObjectRequest.getInputStream();
final PutObjectRequest putInstFileRequest = putObjectRequest.clone()
.withFile(null)
.withInputStream(null)
;
putInstFileRequest.setKey(putInstFileRequest.getKey() + DOT
+ DEFAULT_INSTRUCTION_FILE_SUFFIX);
// Create instruction
ContentCryptoMaterial cekMaterial = createContentCryptoMaterial(putObjectRequest);
// Wraps the object data with a cipher input stream; note the metadata
// is mutated as a side effect.
PutObjectRequest req = wrapWithCipher(putObjectRequest, cekMaterial);
// Put the encrypted object into S3
final PutObjectResult result;
try {
result = s3.putObject(req);
} finally {
cleanupDataSource(putObjectRequest, fileOrig, isOrig,
req.getInputStream(), log);
}
// Put the instruction file into S3
s3.putObject(updateInstructionPutRequest(putInstFileRequest,
cekMaterial));
// Return the result of the encrypted object PUT.
return result;
}
示例4: getRequestFile
import com.amazonaws.services.s3.model.PutObjectRequest; //导入方法依赖的package包/类
/**
* Convenience method for getting the file specified in a request.
*/
public static File getRequestFile(final PutObjectRequest putObjectRequest) {
if (putObjectRequest.getFile() != null) return putObjectRequest.getFile();
return null;
}