For APIs where checksums are not required (e.g., PutObject), the SDK defaults to sending a CRC64-NVME checksum. If you need to send no checksum at all (for compatibility with 3rd party S3 services that do not support the new default), set requestChecksumCalculation to Client::RequestChecksumCalculation::WHEN_REQUIRED in your S3ClientConfiguration.
Warning: Disabling checksums means there are no object integrity checks, and data could be corrupted during transmission.
#include <aws/core/Aws.h>
#include <aws/s3/S3Client.h>
#include <aws/s3/model/PutObjectRequest.h>
using namespace Aws;
using namespace Aws::S3;
using namespace Aws::S3::Model;
namespace {
constexpr const char* LOG_TAG = "TestApplication";
constexpr const char* BUCKET_NAME = "BUCKET_NAME";
constexpr const char* KEY = "OBJECT_KEY";
}
auto main() -> int {
SDKOptions options;
options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Debug;
InitAPI(options);
{
S3ClientConfiguration configuration;
configuration.checksumConfig.requestChecksumCalculation =
Client::RequestChecksumCalculation::WHEN_REQUIRED;
S3Client client{configuration};
auto request = PutObjectRequest().WithBucket(BUCKET_NAME).WithKey(KEY);
std::shared_ptr<IOStream> body = Aws::MakeShared<StringStream>(LOG_TAG,
"sample text stream");
request.SetBody(body);
const auto response = client.PutObject(request);
assert(response.IsSuccess());
}
ShutdownAPI(options);
return 0;
}