Home > other >  Consult with AWS c + + version of the SDK development problems, online etc.!
Consult with AWS c + + version of the SDK development problems, online etc.!

Time:10-10

I started with c + + version of the AWS SDK development, aimed at the Linux environment, develop a call AWS - SDK to upload files to the cloud of function module, the source code package is AWS - SDK - CPP - master. Zip, I have to compile the source code package installation is successful, but as a result of c + + call routines almost have no, I get confused about in those interface code, I found this in the official website (https://aws.amazon.com/cn/blogs/developer/using-cmake-exports-with-the-aws-sdk-for-c/), a routine, I will this code is saved as a file TestUseAWS. CPP:

#include
#include
#include
#include

Using the namespace Aws: : S3;
Using the namespace Aws: : S3: : Model;

The static const char * KEY="s3_cpp_sample_key";
The static const char * BUCKET="s3 - CPP - sample - BUCKET";

Int main ()
{
S3Client client;

//first put an object into s3
PutObjectRequest PutObjectRequest;
PutObjectRequest. WithKey (KEY)
WithBucket (BUCKET);

//this can be any arbitrary stream (i.e fstream, stringstream etc... )
Auto requestStream=Aws: : MakeShared (" s3 - sample ");
* requestStream & lt; <"Hello World!" ;

//set the stream that will be put to the s3
PutObjectRequest. SetBody (requestStream);

Auto putObjectOutcome=client. PutObject (putObjectRequest);

If (putObjectOutcome IsSuccess ())
{
STD: : cout & lt; <"Put the object succeeded" & lt; }
The else
{
STD: : cout & lt; <"Error while putting the Object" & lt; "" & lt; }

//now get the object back out of s3. The response stream can be overridden here if you want it to go directly to
//a file. In this case the default string buf is exactly what we want.
GetObjectRequest GetObjectRequest;
GetObjectRequest. WithBucket (buckets)
WithKey (KEY);

Auto getObjectOutcome=client. GetObject (getObjectRequest);

If (getObjectOutcome IsSuccess ())
{
STD: : cout & lt; <"Successfully retrieved object from the s3 with value:" & lt; STD: : cout & lt; }
The else
{
STD: : cout & lt; <"Error while getting the object" & lt; "" & lt; }

return 0;
}
The above code was compiled connection to pass on my machine, but in the run times wrong, I input command to:
(1) the g + + - c - w - STD=c + + 11 - I aws - SDK - CPP - master/aws - CPP - SDK - core/include -i aws - SDK - CPP - master/aws - CPP - SDK - s3/include TestUseAWS. CPP

(2) the g + + - o TestUseAWS - L/usr/local/lib/Linux/ia32 TestUseAWS. O - laws - CPP - SDK - core - laws - CPP - SDK - s3

(3) the Export LD_LIBRARY_PATH=/usr/local/lib/Linux/ia32: $LD_LIBRARY_PATH

(4)./TestUseAWS

Error:
* * * Error in '/TestUseAWS' : free () : invalid pointer: 0 x00e31064 Aborted * * *
Have the following questions:
(1) set breakpoints, found that in the first sentence S3Client client; Error, don't know what's wrong;
(2) from putObjectRequest. WithKey (KEY). WithBucket (BUCKET); As if, in this sentence, only need to provide the Key and BUCKET can PUT up the information, but don't log on to the AWS need account name?
Excuse me, what a great god used c + + the BBS of AWS - SDK, can help solve? In addition, the presence of some information about the using c + + SDK or method can share, thanks a lot!

CodePudding user response:

Brother, I also met the same problem, also is this routine, your question is how to get rid of the
I display can not connect to the endpoint

CodePudding user response:

Key and bucket is want to go to the application, or routines that can use the above

CodePudding user response:

Can say how to compile under Linux installation aws - SDK - CPP source package?

CodePudding user response:

Can say how to compile under Linux installation aws - SDK - CPP source package?

CodePudding user response:

AWS credentials are used to identify, so you need to register an AWS account, the first year, many services free of charge, then use your account to the public security key and private security key on your system configuration credentials, you can refer to: https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/credentials.html

In addition, any other c + + development example of aws can also refer to the page link, and other more system,

CodePudding user response:

I encountered a similar problem, you need to compile the SDK to again plus options - DCUSTOM_MEMORY_MANAGEMENT=OFF,

CodePudding user response:

Key and bucket should create good, first to use, and, of course, go to the first account,
  •  Tags:  
  • AWS
  • Related