so I am trying to upload a local file to aws s3 using the aws sdk cpp. Here is the sample code that I took from an issue here
#include <aws/core/Aws.h>
#include <aws/s3/S3Client.h>
#include <aws/core/utils/HashingUtils.h>
#include <aws/s3/model/PutObjectRequest.h>
#include <iostream>
#include <fstream>
using namespace Aws::S3::Model;
using namespace std;
using namespace Aws::Utils;
static const char* KEY = "try.txt";
static const char* BUCKET = "bucket-name";
int main()
{
Aws::SDKOptions options;
Aws::InitAPI(options);
Aws::Client::ClientConfiguration myConf;
myConf.region = Aws::Region::US_EAST_2;
Aws::S3::S3Client s3_client(myConf);
const Aws::String bucket_name = BUCKET;
const Aws::String key_name = KEY;
const Aws::String dir_name = "C:/Users/linda.naoui/source/repos/Upload s3";
std::cout << "Uploading " << key_name << " to S3 bucket: " <<
bucket_name << std::endl;
Aws::S3::Model::PutObjectRequest object_request;
object_request.WithBucket(bucket_name).WithKey(key_name);
auto input_data = Aws::MakeShared<Aws::FStream>(key_name.c_str(), dir_name.c_str(), std::ios_base::in);
object_request.SetBody(input_data);
auto put_object_outcome = s3_client.PutObject(object_request);
if (put_object_outcome.IsSuccess()) {
std::cout << "Done!" << std::endl;
}
else {
std::cout << "PutObject error: " <<
put_object_outcome.GetError().GetExceptionName() << " " <<
put_object_outcome.GetError().GetMessage() << std::endl;
}
Aws::ShutdownAPI(options);
return 0;
}
I have a lot of similar errors all related to the dll import, I am installed the aws s3 sdk and aws sdk core using Nuget Package and I am currently on Visual Studio 2019.
Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __thiscall Aws::S3::Model::PutObjectResult::~PutObjectResult(void)" (__imp_??1PutObjectResult@Model@S3@Aws@@QAE@XZ) referenced in function "public: __thiscall Aws::Utils::Outcome >::~Outcome >(void)" (??1?$Outcome@VPutObjectResult@Model@S3@Aws@@V?$AWSError@W4S3Errors@S3@Aws@@@Client@4@@Utils@Aws@@QAE@XZ) Upload s3 C:\Users\linda.naoui\source\repos\Upload s3\Upload s3\S3.obj 1
Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol "__declspec(dllimport) void __cdecl Aws::InitAPI(struct Aws::SDKOptions const &)" (__imp_?InitAPI@Aws@@YAXABUSDKOptions@1@@Z) referenced in function _main Upload s3 C:\Users\linda.naoui\source\repos\Upload s3\Upload s3\S3.obj 1
I am not sure if the problem is because the linkage window is empty