UWP C++ Amazon Web Services S3 - Http Request Error

2021-01-12T20:03:35.663+00:00

I'm trying to attach a function to upload a file directly to my bucket in s3 on my UWP's Application, but I'm getting this error: Unable to parse ExceptionName: BadRequest Message: An error occurred when parsing the HTTP request

Here's my S3 upload function code:

Aws::Client::ClientConfiguration config;
config.region = Aws::Region::SA_EAST_1;

Aws::S3::S3Client s3_client(credentials, config);

Aws::S3::Model::PutObjectRequest request;
request.SetBucket(bucketName);
request.SetKey(objectKey);

std::shared_ptr<Aws::IOStream> input_data =
Aws::MakeShared<Aws::FStream>("SampleAllocationTag",
objectName.c_str(),
std::ios_base::in | std::ios_base::binary);

request.SetBody(input_data);

Aws::S3::Model::PutObjectOutcome outcome =
s3_client.PutObject(request);

if (outcome.IsSuccess()) return true;
else
{
std::string sToConvert = outcome.GetError().GetMessage();
std::wstring w_str = std::wstring(sToConvert.begin(), sToConvert.end());
const wchar_t* w_chars = w_str.c_str();
Windows::UI::Popups::MessageDialog msg(ref new Platform::String(w_chars));
msg.Title = "Database Error";
msg.ShowAsync();
return false;
}

What can i do to fix it? How can i upload a file in UWP with S3 service by Amazon Web Services (AWS) SDK C++ ? :/

Community Center Not monitored
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.