| 104 | } |
| 105 | |
| 106 | std::string download_and_encode_file( |
| 107 | Aws::S3::S3Client const& client, |
| 108 | Aws::String const& bucket, |
| 109 | Aws::String const& key, |
| 110 | Aws::String& encoded_output) |
| 111 | { |
| 112 | using namespace Aws; |
| 113 | |
| 114 | S3::Model::GetObjectRequest request; |
| 115 | request.WithBucket(bucket).WithKey(key); |
| 116 | |
| 117 | auto outcome = client.GetObject(request); |
| 118 | if (outcome.IsSuccess()) { |
| 119 | AWS_LOGSTREAM_INFO(TAG, "Download completed!"); |
| 120 | auto& s = outcome.GetResult().GetBody(); |
| 121 | return encode(s, encoded_output); |
| 122 | } |
| 123 | else { |
| 124 | AWS_LOGSTREAM_ERROR(TAG, "Failed with error: " << outcome.GetError()); |
| 125 | return outcome.GetError().GetMessage(); |
| 126 | } |
| 127 | } |