Closed
Description
What platform/OS are you using?
Ubuntu 14.04
Which version of the SDK?
Tag - 1.7.144
What compiler are you using? what version?
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4
What are your CMake arguments?
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY="s3" ..
Can you provide a TRACE level log? (sanitize any sensitive information)
No errors are detected but the file fails to download. Here is a snippet of the code i am running.
#include <aws/core/Aws.h>
#include <aws/s3/S3Client.h>
#include <aws/s3/model/GetObjectRequest.h>
#include <aws/s3/model/GetObjectResult.h>
#include <aws/core/auth/AWSCredentialsProvider.h>
Aws::SDKOptions options;
pthread_cond_t service_cond = PTHREAD_COND_INITIALIZER;
pthread_mutex_t service_mutex = PTHREAD_MUTEX_INITIALIZER;
void GetObjectAsyncCallback(const Aws::S3::Model::GetObjectRequest& request,
const Aws::S3::Model::GetObjectOutcome& outcome) {
Aws::String filename = request.GetKey();
if (outcome.IsSuccess()) {
std::cout << "Async download successful for filename " << filename.c_str() << std::endl;
}
else {
std::cout << "Get object error " << outcome.GetError().GetExceptionName().c_str() << outcome.GetError().GetMessage().c_str() << std::endl;
}
pthread_cond_signal(&service_cond);
}
/**
* Get an object from an Amazon S3 bucket.
*/
int main(int argc, char** argv)
{
if (argc < 3)
{
std::cout << std::endl <<
"To run this example, supply the name of an S3 bucket and object to"
<< std::endl << "download from it." << std::endl << std::endl <<
"Ex: get_object <bucketname> <filename>\n" << std::endl;
exit(1);
}
options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Debug;
Aws::InitAPI(options);
{
const Aws::String bucket_name = argv[1];
const Aws::String key_name = argv[2];
std::cout << "Downloading " << key_name << " from S3 bucket: " <<
bucket_name << std::endl;
Aws::Client::ClientConfiguration config;
config.endpointOverride = "localhost:9000";
auto credentials = Aws::Auth::AWSCredentials("XXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXX");
Aws::S3::S3Client s3_client = Aws::S3::S3Client(credentials, config, Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Always, false);
//Aws::S3::S3Client s3_client(config);
Aws::S3::Model::GetObjectRequest object_request;
object_request.WithBucket(bucket_name).WithKey(key_name);
auto context = Aws::MakeShared<Aws::Client::AsyncCallerContext>("");
auto callback = [=](const Aws::S3::S3Client* client,
const Aws::S3::Model::GetObjectRequest& request,
const Aws::S3::Model::GetObjectOutcome& outcome,
const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) {
GetObjectAsyncCallback(request, outcome);
};
pthread_mutex_lock(&service_mutex);
s3_client.GetObjectAsync(object_request, callback, context);
pthread_cond_wait(&service_cond, &service_mutex);
pthread_mutex_unlock(&service_mutex);
}
Aws::ShutdownAPI(options);
}
The callback function returns an outcome with status success. But the file is not found locally. Can someone please tell me if I am doing anything wrong.
P.S - I cannot use TransferManager due to various constraints.