Closed bboy-hui closed 8 months ago
As you are able to generate presigned URL for play.min.io
and the generated URL works fine, the issue should be outside of minio-cpp
i.e. you might have passed wrong values to execute the generated URL.
Please share URLs you generated using mc
and minio-cpp
.
minio-cpp: http://192.168.15.17:9000/whotest/photo.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=Q3AM3UQ867SPQQA43P2F%2F20240305%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240305T092833Z&X-Amz-Expires=604800&X-Amz-Signature=82b0e4372f2b4763270a5be87ae64ea80bbf7c733ec8a98404eef0b8686bf194&X-Amz-SignedHeaders=host mc: http://192.168.15.17:9000/whotest/photo.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=Q3AM3UQ867SPQQA43P2F%2F20240305%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240305T093356Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=5303583c97dd5057dad7c3281d87667383f5fcf838d0e425a38971e47636b757
thank you
I do not see any difference. How did you execute these URLs?
thank you ,I used the wrong execution tool.
Hello, I mistakenly thought that I was using the wrong tool.The URLs I used are as follows: When I use the PUT method to obtain a presigned URL for uploading files, the generated URL is also unusable, but it works when I use the minio-python SDK.
I am able to reproduce this issue locally.
I encountered an issue when generating a presigned URL using the
GetPresignedObjectUrl()
method from the MinIO C++ SDK. Upon attempting to access this URL, I received an error indicating that "The request signature we calculated does not match the signature you provided. Check your key and signing method (SignatureDoesNotMatch)." I have verified that both myaccesskey
andsecretkey
are correct.My MinIO server is deployed using Docker. The SDK version was the latest, compiled from the official GitHub repository. Notably, when I obtain a presigned URL using the
mc
client, the generated URL works fine. Moreover, if I use the same SDK to access the official MinIO demo server atplay.min.io
, the URL returned by the same code also works properly. I have also checked the system time synchronization to ensure that the time on my client and server is in sync.Could you please help me identify the possible cause of this issue?
code:
include "client.h"
int main(int argc, char* argv[]) { // Create S3 base URL. minio::s3::BaseUrl base_url("192.168.15.17:9000",false);
// Create credential provider. minio::creds::StaticProvider provider( "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
// Create S3 client."youraccesskey", "yoursecretkey" minio::s3::Client client(base_url, &provider); // Create bucket exists arguments. minio::s3::BucketExistsArgs args; args.bucket = "whotest";
// Call bucket exists. minio::s3::BucketExistsResponse resp = client.BucketExists(args);
// Handle response. if (resp) { if (resp.exist) { std::cout << "my-bucket exists" << std::endl; } else { std::cout << "my-bucket does not exist" << std::endl; } } else { std::cout << "unable to do bucket existence check; " << resp.Error().String() << std::endl; }
// Create get presigned object url arguments. minio::s3::GetPresignedObjectUrlArgs args1;
args1.bucket = "whotest"; args1.object = "photo.png"; args1.method = minio::http::Method::kGet; args1.expiry_seconds = 60 60 24 * 7; // 7 day.
// Call get presigned object url. minio::s3::GetPresignedObjectUrlResponse resp1 = client.GetPresignedObjectUrl(args1);
// Handle response. if (resp1) { std::cout << "presigned URL to get object: " << resp1.url << std::endl; } else { std::cout << "unable to get presigned object url; " << resp1.Error().String() << std::endl; }
return 0; }