minio / minio-cpp

MinIO C++ Client SDK for Amazon S3 Compatible Cloud Storage
https://minio-cpp.min.io/
Apache License 2.0
135 stars 56 forks source link

`BaseClient::GetPresignedPostFormData` always returns `unable to get presigned post form data; valid policy must be provided` #136

Closed ijoseph closed 6 months ago

ijoseph commented 6 months ago

Because !policy is always true here: https://github.com/minio/minio-cpp/blob/f5132e0f390b410361149fb48c05458558815804/src/baseclient.cc#L1070

because the policy should be valid if it has an expiration, not if it lacks one -- this change is needed:

diff --git a/include/miniocpp/args.h b/include/miniocpp/args.h
index 2010b56..8132771 100644
--- a/include/miniocpp/args.h
+++ b/include/miniocpp/args.h
@@ -570,7 +570,7 @@ struct PostPolicy {

   ~PostPolicy() = default;

-  explicit operator bool() const { return !bucket.empty() && !expiration_; }
+  explicit operator bool() const { return !bucket.empty() && (bool) expiration_; }

   error::Error AddEqualsCondition(std::string element, std::string value);
   error::Error RemoveEqualsCondition(std::string element);
balamurugana commented 6 months ago

@ijoseph feel free to send a PR

balamurugana commented 6 months ago

fixed by https://github.com/minio/minio-cpp/pull/137