我正在第一次尝试将文件上传到s3存储桶:
#include <iostream>
#include <aws/core/Aws.h>
#include <aws/s3/S3Client.h>
#include <aws/s3/model/PutObjectRequest.h>
#include <aws/core/auth/AWSCredentialsProvider.h>
#include <iostream>
#include <fstream>
#include <sys/stat.h>
#include <curl/curl.h>
using namespace Aws::Auth;
using namespace Aws::Http;
using namespace Aws::Client;
using namespace Aws::S3;
using namespace Aws::S3::Model;
using namespace Aws::Utils;
int main(int argc, const char * argv[]) {
Aws::SDKOptions options;
Aws::InitAPI(options);
ClientConfiguration clientConfig;
//config.region = "us-west-2";
clientConfig.scheme = Aws::Http::Scheme::HTTPS;
clientConfig.region = Aws::Region::US_EAST_2;
clientConfig.connectTimeoutMs = 30000;
clientConfig.requestTimeoutMs = 600000;
clientConfig.enableHostPrefixInjection = true;
static const char * ACCESS_KEY_ID = "myKey";
static const char * SECRET_KEY = "mySecretKey";
static const char * ALLOCATION_TAG = "SampleAllocationTag";
static const char * filename = "myFilename";
std::shared_ptr<S3Client> client = Aws::MakeShared<S3Client>(
ALLOCATION_TAG,
AWSCredentials(Aws::String(ACCESS_KEY_ID), Aws::String(SECRET_KEY)),
clientConfig
);
Aws::S3::Model::PutObjectRequest object_request;
object_request.SetBucket("myBucketName");
//object_request.SetKey(s3_object_name);
const std::shared_ptr<Aws::IOStream> input_data =
Aws::MakeShared<Aws::FStream>(ALLOCATION_TAG,
filename,
std::ios_base::in | std::ios_base::binary);
object_request.SetBody(input_data);
// Put the object
auto put_object_outcome = client->PutObject(object_request);
if (!put_object_outcome.IsSuccess()) {
auto error = put_object_outcome.GetError();
std::cout << "ERROR: " << error.GetExceptionName() << ": "
<< error.GetMessage() << std::endl;
}
Aws::ShutdownAPI(options);
return 0;
}
我遇到以下错误:
错误:MalformedXML:无法解析ExceptionName:MalformedXML消息:您提供的XML格式不正确或未针对我们发布的架构进行验证
这是什么意思以及如何解决?