Click here to Skip to main content
15,879,490 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I've borrowed a load of code from the AWS SDK CPP guide and boiled it down to this:
C++
const Aws::String& 
objectName = "file.txt";
Aws::Client::ClientConfiguration clientConfig;
clientConfig.scheme = Aws::Http::Scheme::HTTPS;
clientConfig.connectTimeoutMs = 30000;
clientConfig.requestTimeoutMs = 600000;
Aws::S3::S3Client s3_client(clientConfig);
	
Aws::S3::Model::PutObjectRequest putObjectRequest;
putObjectRequest.SetBucket("test-bucket");
putObjectRequest.SetKey(objectName);

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

putObjectRequest.SetBody(input_data);
Aws::S3::Model::PutObjectOutcome outcome = s3_client.PutObject(putObjectRequest);
However when I compile it comes up with this error
Error	C2440	'initializing': cannot convert from 'std::shared_ptr<aws::fstream>' to 'std::shared_ptr<aws::iostream>'
I can't for the life of me figure out what I've done wrong as I've literally copied this verbatim from the website.

What I have tried:

I've discovered that IOStream and FStream aren't interchangeable, which was my first thought and after that I literally have no idea as all the examples on the web are identical to what I have.

Any help much appreciated.
Posted
Updated 19-Jul-22 8:56am
v2
Comments
Richard MacCutchan 19-Jul-22 15:18pm    
Can you provide the link to the place you copied it from?

1 solution

Try including fstream at the top and that should solve the problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900