This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Easy way to upload a local text file to AWS S3 Bucket using the AWS SDK.
Simple as this really, I've tried copying the examples in the guide but get an error stating it can't convert from std::shared_ptr<aws::fstream> to std::shared_ptr<aws::iostream>
At a loss really as this pretty much seems to be the only way I can find in Google.
Here's my code
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("my-bucket"); putObjectRequest.SetKey("file.txt");
// This next line errors
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);
And here's the full error
Error C2440 'initializing': cannot convert from 'std::shared_ptr<Aws::FStream>' to 'std::shared_ptr<Aws::IOStream>'
Thanks in advance
Subreddit
Post Details
- Posted
- 2 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/cpp_questio...