Search in sources :

Example 1 with InstructionFileId

use of com.qcloud.cos.model.InstructionFileId in project cos-java-sdk-v5 by tencentyun.

the class COSEncryptionClient method deleteObject.

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

Example 2 with InstructionFileId

use of com.qcloud.cos.model.InstructionFileId in project cos-java-sdk-v5 by tencentyun.

the class COSCryptoModuleBase method createInstructionPutRequest.

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

Aggregations

COSObjectId (com.qcloud.cos.model.COSObjectId)2 InstructionFileId (com.qcloud.cos.model.InstructionFileId)2 LengthCheckInputStream (com.qcloud.cos.internal.LengthCheckInputStream)1 ReleasableInputStream (com.qcloud.cos.internal.ReleasableInputStream)1 ResettableInputStream (com.qcloud.cos.internal.ResettableInputStream)1 SdkFilterInputStream (com.qcloud.cos.internal.SdkFilterInputStream)1 ObjectMetadata (com.qcloud.cos.internal.crypto.CryptoStorageMode.ObjectMetadata)1 AbstractPutObjectRequest (com.qcloud.cos.model.AbstractPutObjectRequest)1 DeleteObjectRequest (com.qcloud.cos.model.DeleteObjectRequest)1 ObjectMetadata (com.qcloud.cos.model.ObjectMetadata)1 PutObjectRequest (com.qcloud.cos.model.PutObjectRequest)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1