Search in sources :

Example 1 with InstructionFileId

use of com.amazonaws.services.s3.model.InstructionFileId in project aws-sdk-android by aws-amplify.

the class S3CryptoModuleBase method createInstructionPutRequest.

protected final PutObjectRequest createInstructionPutRequest(String bucketName, String key, ContentCryptoMaterial cekMaterial) {
    final byte[] bytes = cekMaterial.toJsonString(cryptoConfig.getCryptoMode()).getBytes(UTF8);
    final InputStream is = new ByteArrayInputStream(bytes);
    final ObjectMetadata metadata = new ObjectMetadata();
    metadata.setContentLength(bytes.length);
    metadata.addUserMetadata(Headers.CRYPTO_INSTRUCTION_FILE, "");
    final InstructionFileId ifileId = new S3ObjectId(bucketName, key).instructionFileId();
    return new PutObjectRequest(ifileId.getBucket(), ifileId.getKey(), is, metadata);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) LengthCheckInputStream(com.amazonaws.util.LengthCheckInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ReleasableInputStream(com.amazonaws.internal.ReleasableInputStream) ResettableInputStream(com.amazonaws.internal.ResettableInputStream) SdkFilterInputStream(com.amazonaws.internal.SdkFilterInputStream) InputStream(java.io.InputStream) InstructionFileId(com.amazonaws.services.s3.model.InstructionFileId) S3ObjectId(com.amazonaws.services.s3.model.S3ObjectId) ObjectMetadata(com.amazonaws.services.s3.model.ObjectMetadata) ObjectMetadata(com.amazonaws.services.s3.model.CryptoStorageMode.ObjectMetadata) AbstractPutObjectRequest(com.amazonaws.services.s3.model.AbstractPutObjectRequest) PutObjectRequest(com.amazonaws.services.s3.model.PutObjectRequest)

Example 2 with InstructionFileId

use of com.amazonaws.services.s3.model.InstructionFileId in project aws-sdk-android by aws-amplify.

the class AmazonS3EncryptionClient method deleteObject.

@Override
public void deleteObject(DeleteObjectRequest req) {
    req.getRequestClientOptions().appendUserAgent(USER_AGENT);
    // Delete the object
    super.deleteObject(req);
    // If it exists, delete the instruction file.
    InstructionFileId ifid = new S3ObjectId(req.getBucketName(), req.getKey()).instructionFileId();
    DeleteObjectRequest instructionDeleteRequest = (DeleteObjectRequest) req.clone();
    instructionDeleteRequest.withBucketName(ifid.getBucket()).withKey(ifid.getKey());
    super.deleteObject(instructionDeleteRequest);
}
Also used : DeleteObjectRequest(com.amazonaws.services.s3.model.DeleteObjectRequest) InstructionFileId(com.amazonaws.services.s3.model.InstructionFileId) S3ObjectId(com.amazonaws.services.s3.model.S3ObjectId)

Aggregations

InstructionFileId (com.amazonaws.services.s3.model.InstructionFileId)2 S3ObjectId (com.amazonaws.services.s3.model.S3ObjectId)2 ReleasableInputStream (com.amazonaws.internal.ReleasableInputStream)1 ResettableInputStream (com.amazonaws.internal.ResettableInputStream)1 SdkFilterInputStream (com.amazonaws.internal.SdkFilterInputStream)1 AbstractPutObjectRequest (com.amazonaws.services.s3.model.AbstractPutObjectRequest)1 ObjectMetadata (com.amazonaws.services.s3.model.CryptoStorageMode.ObjectMetadata)1 DeleteObjectRequest (com.amazonaws.services.s3.model.DeleteObjectRequest)1 ObjectMetadata (com.amazonaws.services.s3.model.ObjectMetadata)1 PutObjectRequest (com.amazonaws.services.s3.model.PutObjectRequest)1 LengthCheckInputStream (com.amazonaws.util.LengthCheckInputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1