Skip to content

Commit

Permalink
Updated examples to use the default account region.
Browse files Browse the repository at this point in the history
  • Loading branch information
irenepsmith committed May 14, 2021
1 parent 8b23816 commit e6777b4
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 140 deletions.
3 changes: 1 addition & 2 deletions dotnetv3/S3/CopyObjectExample/CopyObject/CopyObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace CopyObject
public class CopyObject
{
// Specify the AWS Region where your buckets are located (an example Region is shown).
private static readonly RegionEndpoint BUCKET_REGION = RegionEndpoint.USWest2;
private static IAmazonS3 _s3Client;

// Remember to change these values to refer to your own Amazon S3 objects.
Expand All @@ -29,7 +28,7 @@ public class CopyObject

static async Task Main()
{
_s3Client = new AmazonS3Client(BUCKET_REGION);
_s3Client = new AmazonS3Client();

Console.WriteLine($"Copying {SOURCE_OBJ_KEY} from {SOURCE_BUCKET_NAME} to ");
Console.WriteLine($"{DESTINATION_BUCKET_NAME} as {DESTINATION_OBJ_KEY}");
Expand Down
11 changes: 2 additions & 9 deletions dotnetv3/S3/CreateBucketExample/CreateBucket/CreateBucket.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX - License - Identifier: Apache - 2.0

// snippet-start:[S3.dotnet35.CreateBucket]

using Amazon;
using Amazon.S3;
using Amazon.S3.Model;
using Amazon.S3.Util;
using System;
using System.Threading.Tasks;

Expand All @@ -18,17 +14,15 @@ public class CreateBucket
// to create a new Amazon S3 bucket. The examples uses AWS SDK for .NET 3.5 and
// .NET 5.0.

// Specify your AWS Region (an example Region is shown).
private static readonly RegionEndpoint BUCKET_REGION = RegionEndpoint.USEast1; // RegionEndpoint.USWest2;
private static IAmazonS3 _s3Client;

// Specify the name of the new bucket.
private const string NEW_BUCKET_NAME = "igsmith-bucket2"; // "doc-example-bucket";
private const string NEW_BUCKET_NAME = "doc-example-bucket";

static async Task Main()
{

_s3Client = new AmazonS3Client(BUCKET_REGION);
_s3Client = new AmazonS3Client();
Console.WriteLine($"\nCreating a new bucket, named: {NEW_BUCKET_NAME}.");

await CreatingBucketAsync(_s3Client, NEW_BUCKET_NAME);
Expand Down Expand Up @@ -61,4 +55,3 @@ static async Task CreatingBucketAsync(IAmazonS3 client, string bucketName)
}
}
}
// snippet-end:[S3.dotnet35.CreateBucket]
8 changes: 1 addition & 7 deletions dotnetv3/S3/DeleteBucketExample/DeleteBucket/DeleteBucket.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX - License - Identifier: Apache - 2.0

// snippet-start:[S3.dotnet35.DeleteBucket]

using Amazon;
using Amazon.S3;
using System;
Expand All @@ -15,17 +13,14 @@ class DeleteBucket
// This example shows how to delete an existing empty bucket.
// The examples uses AWS SDK for .NET 3.5 and .NET 5.0

// Change the name of the following constant to the AWS Region containing your bucket
// The value below is just an example.
private static readonly RegionEndpoint BUCKET_REGION = RegionEndpoint.USWest2;
private static IAmazonS3 _s3Client;

// Specify the name of the bucket to delete.
private const string BUCKET_NAME = "doc-example-bucket";

static async Task Main()
{
_s3Client = new AmazonS3Client(BUCKET_REGION);
_s3Client = new AmazonS3Client();

// Now delete the bucket. If the bucket you are trying to
// delete contains any objects, the call will raise an exception.
Expand Down Expand Up @@ -53,4 +48,3 @@ static async Task DeletingBucketAsync(IAmazonS3 client, string bucketName)
}
}
}
// snippet-end:[S3.dotnet35.DeleteBucket]
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ namespace DeleteBucketText
{
public class DeleteBucketTest
{
// This example deletes an existing Amazon Simple Storage Service (S3)
// bucket. It uses the AWS SDK for .NET 3.5 and .NET 5.0.

private string _BucketName;

private IAmazonS3 CreateMockS3Client()
Expand Down
7 changes: 4 additions & 3 deletions dotnetv3/S3/ListBucketsExample/ListBuckets/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@

namespace ListBuckets
{
// This example uses the AWS SDK for .NET to list the Amazon Simple Storage
// Service (Amazon S3) buckets belonging to the default account. This code
// was written using AWS SDK for .NET v3.5 and .NET Core 5.0.
class ListBuckets
{
// Specify your AWS Region (an example Region is shown).
private static readonly RegionEndpoint BUCKET_REGION = RegionEndpoint.USWest2;
private static IAmazonS3 _s3Client;

static async Task Main(string[] args)
{
_s3Client = new AmazonS3Client(BUCKET_REGION);
_s3Client = new AmazonS3Client();
var response = await GetBuckets(_s3Client);
DisplayBucketList(response.Buckets);
}
Expand Down
7 changes: 1 addition & 6 deletions dotnetv3/S3/ListObjectsExample/ListObjects/ListObjects.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX - License - Identifier: Apache - 2.0

// snippet-start:[S3.dotnet35.ListObjects]

using Amazon;
using Amazon.S3;
using Amazon.S3.Model;
Expand All @@ -16,15 +14,13 @@ namespace ListObjects
// and .NET 5.0.
public class ListObjects
{
// Specify your AWS Region (an example Region is shown).
private static readonly RegionEndpoint BUCKET_REGION = RegionEndpoint.USWest2;
private static IAmazonS3 _s3Client;

private const string BUCKET_NAME = "doc-example-bucket";

static async Task Main()
{
_s3Client = new AmazonS3Client(BUCKET_REGION);
_s3Client = new AmazonS3Client();

Console.WriteLine($"Listing the objects contained in {BUCKET_NAME}:\n");
await ListingObjectsAsync(_s3Client, BUCKET_NAME);
Expand All @@ -51,4 +47,3 @@ static async Task ListingObjectsAsync(IAmazonS3 client, string bucketName)
}
}
}
// snippet-end:[S3.dotnet35.ListObjects]
4 changes: 1 addition & 3 deletions dotnetv3/S3/UploadObjectExample/UploadObject/UploadObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ namespace UploadObject

class UploadObject
{
// Specify your AWS Region (an example Region is shown).
private static readonly RegionEndpoint BUCKET_REGION = RegionEndpoint.USWest2;
private static IAmazonS3 _s3Client;

private const string BUCKET_NAME = "doc-example-bucket";
Expand All @@ -30,7 +28,7 @@ class UploadObject

static async Task Main()
{
_s3Client = new AmazonS3Client(BUCKET_REGION);
_s3Client = new AmazonS3Client();

// The method expects the full path, including the file name.
var path = $"{LOCAL_PATH}\\{OBJECT_NAME1}";
Expand Down
107 changes: 0 additions & 107 deletions dotnetv3/S3/s3.sln

This file was deleted.

0 comments on commit e6777b4

Please sign in to comment.