-
We have noticed the C++ SDK is not able to download objects with leading forward slash in key, e.g. |
Beta Was this translation helpful? Give feedback.
Answered by
sbiscigl
Feb 20, 2025
Replies: 1 comment 1 reply
-
So this was originally was a issue with how the cpp handled path separators with S3, we could not change the default behavior to match cli/boto by default without breaking existing customers so we made it opt-in(#2891). you can opt in using SetPreservePathSeparators(true); a complete example would look like #include <aws/core/Aws.h>
#include <aws/core/http/URI.h>
#include <aws/s3/S3Client.h>
#include <aws/s3/model/GetObjectRequest.h>
using namespace Aws;
using namespace Aws::Http;
using namespace Aws::S3;
using namespace Aws::S3::Model;
auto main() -> int {
SDKOptions options{};
InitAPI(options);
{
SetPreservePathSeparators(true);
S3ClientConfiguration client_configuration;
S3Client client{};
const auto get_object_outcome = client.GetObject(GetObjectRequest()
.WithBucket(your_bucket)
.WithKey("/tmp/mydoc.txt"));
assert(get_object_outcome.IsSuccess());
std::cout << get_object_outcome.GetResult().GetBody().rdbuf() << "\n";
}
ShutdownAPI(options);
return 0;
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
aokhovat
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So this was originally was a issue with how the cpp handled path separators with S3, we could not change the default behavior to match cli/boto by default without breaking existing customers so we made it opt-in(#2891). you can opt in using
a complete example would look like