src/S3/Crypto/S3EncryptionClient.php
public function getObjectAsync(array $args)
    {
        $provider = $this->getMaterialsProvider($args);
        unset($args['@MaterialsProvider']);

        $instructionFileSuffix = $this->getInstructionFileSuffix($args);
        unset($args['@InstructionFileSuffix']);

        $strategy = $this->getMetadataStrategy($args, $instructionFileSuffix);
        unset($args['@MetadataStrategy']);

        $saveAs = null;
        if (!empty($args['SaveAs'])) {
            $saveAs = $args['SaveAs'];
        }

        $promise = $this->client->getObjectAsync($args)
            ->then(
                function ($result) use (
                    $provider,
                    $instructionFileSuffix,
                    $strategy,
                    $args
                ) {
                    if ($strategy === null) {
                        $strategy = $this->determineGetObjectStrategy(
                            $result,
                            $instructionFileSuffix
                        );
                    }

                    $envelope = $strategy->load($args + [
                        'Metadata' => $result['Metadata']
                    ]);

                    $provider = $provider->fromDecryptionEnvelope($envelope);

                    $result['Body'] = $this->decrypt(
                        $result['Body'],
                        $provider,
                        $envelope,
                        isset($args['@CipherOptions'])
                            ? $args['@CipherOptions']
                            : []
                    );
                    return $result;
                }
            )->then(
                function ($result) use ($saveAs) {
                    if (!empty($saveAs)) {
                        file_put_contents(
                            $saveAs,
                            (string)$result['Body'],
                            LOCK_EX
                        );
                    }
                    return $result;
                }
            );

        return $promise;
    }
public function getObjectAsync(array $args)
    {
        $provider = $this->getMaterialsProvider($args);
        unset($args['@MaterialsProvider']);

        $instructionFileSuffix = $this->getInstructionFileSuffix($args);
        unset($args['@InstructionFileSuffix']);

        $strategy = $this->getMetadataStrategy($args, $instructionFileSuffix);
        unset($args['@MetadataStrategy']);

        $saveAs = null;
        if (!empty($args['SaveAs'])) {
            $saveAs = $args['SaveAs'];
        }

        $promise = $this->client->getObjectAsync($args)
            ->then(
                function ($result) use (
                    $provider,
                    $instructionFileSuffix,
                    $strategy,
                    $args
                ) {
                    if ($strategy === null) {
                        $strategy = $this->determineGetObjectStrategy(
                            $result,
                            $instructionFileSuffix
                        );
                    }

                    $envelope = $strategy->load($args + [
                        'Metadata' => $result['Metadata']
                    ]);

                    $provider = $provider->fromDecryptionEnvelope($envelope);

                    $result['Body'] = $this->decrypt(
                        $result['Body'],
                        $provider,
                        $envelope,
                        isset($args['@CipherOptions'])
                            ? $args['@CipherOptions']
                            : []
                    );
                    return $result;
                }
            )->then(
                function ($result) use ($saveAs) {
                    if (!empty($saveAs)) {
                        file_put_contents(
                            $saveAs,
                            (string)$result['Body'],
                            LOCK_EX
                        );
                    }
                    return $result;
                }
            );

        return $promise;
    }
public function getObjectAsync ( array $ args ) { $ provider = $ this -> getMaterialsProvider ( $ args ) ; unset ( $ args [ '@MaterialsProvider' ] ) ; $ instructionFileSuffix = $ this -> getInstructionFileSuffix ( $ args ) ; unset ( $ args [ '@InstructionFileSuffix' ] ) ; $ strategy = $ this -> getMetadataStrategy ( $ args , $ instructionFileSuffix ) ; unset ( $ args [ '@MetadataStrategy' ] ) ; $ saveAs = null ; if ( ! empty ( $ args [ 'SaveAs' ] ) ) { $ saveAs = $ args [ 'SaveAs' ] ; } $ promise = $ this -> client -> getObjectAsync ( $ args ) -> then ( function ( $ result ) use ( $ provider , $ instructionFileSuffix , $ strategy , $ args ) { if ( $ strategy === null ) { $ strategy = $ this -> determineGetObjectStrategy ( $ result , $ instructionFileSuffix ) ; } $ envelope = $ strategy -> load ( $ args + [ 'Metadata' => $ result [ 'Metadata' ] ] ) ; $ provider = $ provider -> fromDecryptionEnvelope ( $ envelope ) ; $ result [ 'Body' ] = $ this -> decrypt ( $ result [ 'Body' ] , $ provider , $ envelope , isset ( $ args [ '@CipherOptions' ] ) ? $ args [ '@CipherOptions' ] : [ ] ) ; return $ result ; } ) -> then ( function ( $ result ) use ( $ saveAs ) { if ( ! empty ( $ saveAs ) ) { file_put_contents ( $ saveAs , ( string ) $ result [ 'Body' ] , LOCK_EX ) ; } return $ result ; } ) ; return $ promise ; }
Promises to retrieve an object from S3 and decrypt the data in the
'Body' field.

@param array $args Arguments for retrieving an object from S3 via
GetObject and decrypting it.

The required configuration argument is as follows:

- @MaterialsProvider: (MaterialsProvider) Provides Cek, Iv, and Cek
encrypting/decrypting for decryption metadata. May have data loaded
from the MetadataEnvelope upon decryption.

The optional configuration arguments are as follows:

- SaveAs: (string) The path to a file on disk to save the decrypted
object data. This will be handled by file_put_contents instead of the
Guzzle sink.

- @MetadataStrategy: (MetadataStrategy|string|null) Strategy for reading
MetadataEnvelope information. Defaults to determining based on object
response headers. Can either be a class implementing MetadataStrategy,
a class name of a predefined strategy, or empty/null to default.
- @InstructionFileSuffix: (string) Suffix used when looking for an
instruction file if an InstructionFileMetadataHandler is being used.
- @CipherOptions: (array) Cipher options for decrypting data. A Cipher
is required. Accepts the following options:
- Aad: (string) Additional authentication data. This option is
passed directly to OpenSSL when using gcm. It is ignored when
using cbc.

@return PromiseInterface

@throws \InvalidArgumentException Thrown when required arguments are not
passed or are passed incorrectly.
Promises to retrieve an object from S3 and decrypt the data in the Body field .