Skip to content

Conversation

imabhichow
Copy link
Contributor

Issue #, if available:

Description of changes:

  • Multipart Examples
  • Ranged Get examples
  • Async Client Configuration example

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Check any applicable:

  • Were any files moved? Moving files changes their URL, which breaks all hyperlinks to the files.

imabhichow and others added 8 commits February 6, 2023 03:03
… into imabhichow-examples-multipart

# Conflicts:
#	src/examples/java/software/amazon/encryption/s3/examples/MultipartUploadExample.java
#	src/test/java/software/amazon/encryption/s3/examples/MultipartUploadExampleTest.java
@imabhichow imabhichow requested review from kessplas and aliepaoli June 29, 2023 22:41
@imabhichow imabhichow requested a review from a team as a code owner June 29, 2023 22:41
@imabhichow imabhichow requested a review from kwwarmbe August 16, 2023 17:10
}

public static void AsyncClient(String bucket) {
final String input = appendTestSuffix("PutAsyncGetAsync");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to append test suffix to the input

import static software.amazon.encryption.s3.utils.S3EncryptionClientTestResources.appendTestSuffix;

public class AsyncClientExample {
public static final String OBJECT_KEY = "async-client-example";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are missing appending the test suffix here.
Since there's only one test,
we might as well just define the object key inside the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also use this Object Key for clean-up method.


// Instantiate the S3 Encryption Client to encrypt and decrypt
// by specifying a KMS Key with the kmsKeyId builder parameter.
// You must also specify the enableDelayedAuthenticationMode parameter to upload more than 64MB object or increase your default buffer size.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't quite accurate - delayed auth is not required to upload objects larger than 64Mib/configured buffer size, only for download

// Asserts
String inputAsString = IoUtils.toUtf8String(new BoundedInputStream(fileSizeLimit));
String outputAsString = IoUtils.toUtf8String(result.asInputStream());
assertEquals(inputAsString, outputAsString);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should be doing something like:

        assertTrue(IOUtils.contentEquals(objectStreamForResult, output));

to avoid buffering the entire object into String

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack!

public static void simpleAesGcmV3RangedGet(String bucket) {
final String objectKey = appendTestSuffix("simple-v3-ranged-get-example");

// Instantiate the S3 Encryption Client by specifying an AES Key with the aesKey builder parameter.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment refers to AES key but the example uses KMS

v3Client.close();
}

public static void aesGcmV3RangedGetOperations(String bucket) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: let's add a comment mentioning that this example demonstrates how various unusual ranged get cases are handled

Copy link
Contributor

@kessplas kessplas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@imabhichow imabhichow merged commit 203e5dc into main Aug 24, 2023
@imabhichow imabhichow deleted the imabhichow/v3.1-examples branch August 24, 2023 19:35
aws-crypto-tools-ci-bot pushed a commit that referenced this pull request Aug 31, 2023
## [3.1.0](v3.0.1...v3.1.0) (2023-08-31)

### Features

* add configuration option to set max buffer size ([#166](#166)) ([ecf6e6c](ecf6e6c))
* multipart & ranged get examples ([#168](#168)) ([203e5dc](203e5dc))
* Refactor `KmsKeyring` to use `GenerateDataKey` instead of `Encrypt` ([#171](#171)) ([a1a22a4](a1a22a4))

### Fixes

* Create default wrapped clients only if necessary. ([#163](#163)) ([285eab6](285eab6))
* unwrap completion exception in AbortMultipartUpload and inside multipart putObject ([#174](#174)) ([84baad8](84baad8))

### Maintenance

* allow CI to run in forks ([#164](#164)) ([66a5ca4](66a5ca4))
* **deps-dev:** bump bcprov-jdk18on from 1.72 to 1.74 ([#169](#169)) ([5502eab](5502eab))
* fix bugs and nit ([#175](#175)) ([926818b](926818b))
* install dependabot ([#172](#172)) ([1c63fdb](1c63fdb))
* warn against use of Encryption Context for non-kms keyrings. ([#173](#173)) ([54557a9](54557a9))
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.

2 participants