I am trying to use AWS C++ SDK to upload file to s3. However it seems that the existing example does not work. Following is my sample code:
invocation_response putFileObject(S3::S3Client &client, const String& bucketName, const String& objectName) {
const string fileName = "/tmp/test";
auto inputData =
Aws::MakeShared<Aws::FStream>("SampleAllocationTag",
fileName.c_str(),
std::ios_base::in | std::ios_base::binary);
S3::Model::PutObjectRequest request;
request.SetBucket(bucketName);
request.SetKey(objectName);
request.SetBody(inputData);
S3::Model::PutObjectOutcome outcome =
client.PutObject(request);
if (!outcome.IsSuccess()) {
cout << "Failure Putting Object" << endl;
return invocation_response::failure("Error Putobject", "application/json");
}
else {
cout << "Success Putting Object" << endl;
return invocation_response::success("Success Putobject", "application/json");
}
}
I run into the following compilation error:
In function ‘aws::lambda_runtime::invocation_response putFileObject(Aws::S3::S3Client&, const String&, const String&)’: error: cannot convert ‘std::shared_ptrstd::basic_fstream<char >’ to ‘const std::shared_ptrstd::basic_iostream<char >&’
I am sure I am missing something straightforward. Any help would be appreciated.
Tried changing the FStream to OStream and still that did no work