本文整理匯總了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;
}