Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow S3EncryptionClient::putObject to accept any type that implement StreamInterface #2671

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

whizsid
Copy link

@whizsid whizsid commented Apr 10, 2023

putObject is throwing an exception if user passed a stream implemented to StreamInterface. I checked the usage of $plaintext and found that $plaintext is using only for constructors of AesGcmEncryptingStream and AesEncryptingStream. Those constructors requiring StreamInterface as first arguments. So we do not have to stick into Stream in EncryptionTraits.

Now we are doing like this.

$tfh = tmpfile();
fwrite($tfh, (string)$stream);

$result = $encryptedS3Client->putObject([
      '@MaterialsProvider' => $this->kmsProvider,
      '@CipherOptions' => $cipherOptions,
      'Bucket' => $bucket,
      'Key' => $path,
      'Body' => $tfh,
]);

With this PR we can save some cost like this:-

$result = $encryptedS3Client->putObject([
      '@MaterialsProvider' => $this->kmsProvider,
      '@CipherOptions' => $cipherOptions,
      'Bucket' => $bucket,
      'Key' => $path,
      'Body' => $stream,
]);

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@whizsid whizsid changed the title Allow putObject to pass any typeof stream Allow S3EncryptionClient::putObject to pass any type that implement StreamInterface Apr 10, 2023
@whizsid whizsid changed the title Allow S3EncryptionClient::putObject to pass any type that implement StreamInterface Allow S3EncryptionClient::putObject to accept any type that implement StreamInterface Apr 10, 2023
@stobrien89 stobrien89 closed this Jun 1, 2023
@stobrien89 stobrien89 reopened this Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants