test_s3-demo.cpp - AWS Code Sample

test_s3-demo.cpp

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX - License - Identifier: Apache - 2.0 #include <iostream> #include <aws/core/Aws.h> #include <aws/s3/S3Client.h> #include <aws/core/utils/UUID.h> #include <awsdoc/s3/s3-demo.h> int main() { Aws::SDKOptions options; Aws::InitAPI(options); { // Create a unique bucket name to increase the chance of success // when trying to create the bucket. // Format: "my-bucket-" + lowercase UUID. Aws::String uuid = Aws::Utils::UUID::RandomUUID(); Aws::String bucket_name = "my-bucket-" + Aws::Utils::StringUtils::ToLower(uuid.c_str()); Aws::String region = "us-east-1"; Aws::Client::ClientConfiguration config; config.region = region; Aws::S3::S3Client s3_client(config); if (!FindTheBucket(s3_client, bucket_name)) { return 1; } if (!CreateTheBucket(s3_client, bucket_name)) { return 1; } if (!FindTheBucket(s3_client, bucket_name)) { return 1; } if (!DeleteTheBucket(s3_client, bucket_name)) { return 1; } if (!FindTheBucket(s3_client, bucket_name)) { return 1; } } Aws::ShutdownAPI(options); return 0; }