i have file in c++ upload avi file aws s3 storage. program follow.
#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 = "test.avi"; static const char* bucket = "testnmn"; int main() { aws::sdkoptions options; aws::initapi(options); const aws::string bucket_name = bucket; const aws::string key_name = key; const aws::string dir_name = "/home/softwares/projects/s3upload/build"; std::cout << "uploading " << key_name << " s3 bucket: " << bucket_name << std::endl; aws::s3::s3client s3_client; 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; }
when run exe file, have error as
uploading test.avi s3 bucket: testnmn putobject error: permanentredirect unable parse exceptionname: permanentredirect message: bucket attempting access must addressed using specified endpoint. please send future requests endpoint.
what wrong error?
thanks
it looks bucket trying access has been created in different region (than default, believe us-east-1) & hence endpoint not match.
you can set region using clientconfiguration:
aws::client::clientconfiguration myconf; myconf.region = aws::region::us_west_2; aws::s3::s3client s3_client(myconf);
Comments
Post a Comment