| 25 | char const TAG[] = "LAMBDA_ALLOC"; |
| 26 | |
| 27 | static invocation_response my_handler(invocation_request const& req, Aws::S3::S3Client const& client) |
| 28 | { |
| 29 | using namespace Aws::Utils::Json; |
| 30 | JsonValue json(req.payload); |
| 31 | if (!json.WasParseSuccessful()) { |
| 32 | return invocation_response::failure("Failed to parse input JSON", "InvalidJSON"); |
| 33 | } |
| 34 | |
| 35 | auto v = json.View(); |
| 36 | |
| 37 | if (!v.ValueExists("s3bucket") || !v.ValueExists("s3key") || !v.GetObject("s3bucket").IsString() || |
| 38 | !v.GetObject("s3key").IsString()) { |
| 39 | return invocation_response::failure("Missing input value s3bucket or s3key", "InvalidJSON"); |
| 40 | } |
| 41 | |
| 42 | auto bucket = v.GetString("s3bucket"); |
| 43 | auto key = v.GetString("s3key"); |
| 44 | |
| 45 | AWS_LOGSTREAM_INFO(TAG, "Attempting to download file from s3://" << bucket << "/" << key); |
| 46 | |
| 47 | Aws::String base64_encoded_file; |
| 48 | auto err = download_and_encode_file(client, bucket, key, base64_encoded_file); |
| 49 | if (!err.empty()) { |
| 50 | return invocation_response::failure(err, "DownloadFailure"); |
| 51 | } |
| 52 | |
| 53 | return invocation_response::success(std::move(base64_encoded_file), "application/base64"); |
| 54 | } |
| 55 | |
| 56 | std::function<std::shared_ptr<Aws::Utils::Logging::LogSystemInterface>()> GetConsoleLoggerFactory() |
| 57 | { |
no test coverage detected