Skip to content

Updated six S3 examples. #1922

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

Merged
merged 3 commits into from
Jul 26, 2021
Merged

Conversation

irenepsmith
Copy link
Contributor

aws-doc-sdk-examples Pull Request

Thank you for making a submission to the aws-doc-sdk-examples repository. For more information about submitting pull requests to this repository, see Guidelines for contributing.

NOTE: This PR template contains three sections. Depending on the reason for your pull request, please fill out the section that applies to you and then remove the other two sections.

Existing Example Update

The following examples have been updated:

  1. AbortMPUExample
  2. SSECLowLevelMPUcopyObjectExample
  3. SSEClientEncryptionExample
  4. ServerAccessLoggingExample
  5. ServerSideEncryptionExample
  6. UploadUsingPresignedURLExample

The submitter has:

  • Confirmed that the correct copyright is included in all files.
  • Changed or added comments and strings have been reviewed, and the submitter has incorporated any and all suggested edits.

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

{
string bucketName = "doc-example-bucket";

// If the AWS region defined for your default user is different
Copy link
Contributor

Choose a reason for hiding this comment

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

AWS Region on first use , Region thereafter. I won't repeat this comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

string bucketName = "doc-example-bucket";

// If the AWS region defined for your default user is different
// from the AWS regsion where your Amazon S3 bucket is located,
Copy link
Contributor

Choose a reason for hiding this comment

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

Region

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

}

/// <summary>
/// Makes the call to abort the multi-part copy process.
Copy link
Contributor

Choose a reason for hiding this comment

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

Just "Aborts ..."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed

/// <param name="client">The initialized client object used to create
/// the TransferUtility object.</param>
/// <param name="bucketName">The name of the multi-part copy operation
/// is in progress.</param>
Copy link
Contributor

Choose a reason for hiding this comment

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

that is in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

string filePath,
string base64Key)
{
// List to store upload part responses.
Copy link
Contributor

Choose a reason for hiding this comment

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

The list

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I looked at this one, it seems that anyone who knows C# would know his is a generic List of Responses. I removed the comment altogether.

// Upload the object.
PutObjectRequest putObjectRequest = await UploadObjectAsync(client, bucketName, keyName, base64Key);

// Download the object and verify that its contents matche what you uploaded.
Copy link
Contributor

Choose a reason for hiding this comment

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

match

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

await GetObjectMetadataAsync(client, bucketName, keyName, base64Key);

// Copy both the source and target objects using server-side encryption with
// a customer-provided encryption key.
Copy link
Contributor

Choose a reason for hiding this comment

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

delete "customer-provided"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to "an encryption key."

/// </summary>
/// <param name="client">The initialized S3 client object used to call
/// CopyObjectAsync.</param>
/// <param name="bucketName">The S3 bucket containing the object we
Copy link
Contributor

Choose a reason for hiding this comment

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

delete "we wish"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed


/// <summary>
/// This method grants appropriate permissions for logging to the
/// S3 bucket where the logs will be stored.
Copy link
Contributor

Choose a reason for hiding this comment

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

S3 -> Amazon S3. I won't repeat this comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

S3 is correct in this instance. First time Amazon Simple Storage Service (Amazon S3), 2nd time Amazon S3, and third time only S3.

/// file you want to upload.</param>
/// <param name="url">The presigned URL that will be used to upload the
/// file to the S3 bucket.</param>
/// <returns>A boolean value indicating the success or failure of the
Copy link
Contributor

Choose a reason for hiding this comment

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

Boolean

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

string bucketName = "doc-example-bucket";

// If the AWS Region defined for your default user is different
// from the Regsion where your Amazon S3 bucket is located,
Copy link
Contributor

Choose a reason for hiding this comment

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

Region

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

}

/// <summary>
/// Aborts the multi-part copy process.
Copy link
Contributor

Choose a reason for hiding this comment

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

Aborts -> Cancels

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

/// </summary>
/// <param name="client">The initialized client object used to create
/// the TransferUtility object.</param>
/// <param name="bucketName">The name of the multi-part copy operation
Copy link
Contributor

Choose a reason for hiding this comment

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

The parameter name and comment aren't compatible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to:

The name of the S3 bucket where the multi-part copy operation is in progress.

{
var transferUtility = new TransferUtility(client);

// Abort all in-progress uploads initiated before the specified date.
Copy link
Contributor

Choose a reason for hiding this comment

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

Abort -> Cancel

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed

string filePath = $"sample\\{targetKeyName}";

// If the AWS Region defined for your default user is different
// from the Regsion where your Amazon S3 bucket is located,
Copy link
Contributor

Choose a reason for hiding this comment

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

Region

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

/// <summary>
/// Creates the encryption key to use with the multi-part upload.
/// </summary>
/// <returns>A string containing the base64 key for encrypting the
Copy link
Contributor

Choose a reason for hiding this comment

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

base64-encoded

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

string copyTargetKeyName = "examplecopy.txt";

// If the AWS Region defined for your default user is different
// from the Regsion where your Amazon S3 bucket is located,
Copy link
Contributor

Choose a reason for hiding this comment

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

Region

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Console.WriteLine("Error...Object encryption method is not the same as AES256 we set");
}

// Assert.AreEqual(putObjectRequest.ContentBody, content);
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to leave these in here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't have been there. Removed.


GetObjectMetadataResponse getObjectMetadataResponse = await client.GetObjectMetadataAsync(getObjectMetadataRequest);
Console.WriteLine("The object metadata show encryption method used is: {0}", getObjectMetadataResponse.ServerSideEncryptionCustomerMethod);
// Assert.AreEqual(ServerSideEncryptionCustomerMethod.AES256, getObjectMetadataResponse.ServerSideEncryptionCustomerMethod);
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to leave this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't have been there. Removed.

string logObjectKeyPrefix = "Logs";

// If the AWS Region defined for your default user is different
// from the Regsion where your Amazon S3 bucket is located,
Copy link
Contributor

Choose a reason for hiding this comment

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

Region

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also fixed the same error in:
ServerSideEncryptionExample
UploadUsingPresignedURLExample

@brmur brmur assigned brmur and unassigned Doug-AWS Jul 22, 2021
@brmur brmur merged commit c298279 into awsdocs:master Jul 26, 2021
@irenepsmith irenepsmith deleted the update-six-s3-examples branch October 19, 2021 14:41
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.

3 participants