public CompletableFuture putObjectSecurely()

in oss-20190517/src/main/java/com/aliyun/sdk/service/oss20190517/encryption/internal/CryptoModuleBase.java [68:95]


    public CompletableFuture<PutObjectResponse> putObjectSecurely(PutObjectRequest request) {
        // Update User-Agent.

        // Build content crypto material.
        ContentCryptoMaterial cekMaterial = createContentCryptoMaterialDefault();

        // generate crypto the metadata
        Map<String, String> metadata = generateCryptoMetadata(cekMaterial, request.getHeaderParameters());
        if (request.getMetaData() != null) {
            metadata.putAll(request.getMetaData());
        }

        // Wraps the object data with a cipher input stream
        CryptoCipher cryptoCipher = createEncryptCryptoCipher(cekMaterial, null, 0);
        InputStream body = request.getBody();
        if (body != null) {
            body = new RenewableCipherInputStream(body, cryptoCipher, DEFAULT_BUFFER_SIZE);
        }

        PutObjectRequest req = request.toBuilder()
                .metaData(metadata)
                .body(body)
                .build();
        req.getHeaderParameters().remove("Content-MD5");

        // Put the encrypted object by the oss client
        return ossDirect.putObject(req);
    }