Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status code in PutObjectResponse is internal, unlike AWS S3's implementation #1176

Open
minhaz109074 opened this issue Sep 11, 2024 · 2 comments

Comments

@minhaz109074
Copy link


Description:

In the MinIO .NET SDK, I encountered an issue where the HttpStatusCode in the PutObjectResponse is internal, making it inaccessible after receiving a response. However, in AWS S3's SDK, the same property is public, which allows developers to easily access the status code of the operation.

Code:

Here’s an example of how the MinIO SDK currently handles the HttpStatusCode:

public class GenericResponse
{
    internal GenericResponse(HttpStatusCode statusCode, string responseContent)
    {
        ResponseContent = responseContent;
        ResponseStatusCode = statusCode;
    }

    internal string ResponseContent { get; }
    internal HttpStatusCode ResponseStatusCode { get; }
}

public class PutObjectResponse : GenericResponse
{
}

Suggestion:

Please consider changing the visibility of ResponseStatusCode from internal to public to align with the behavior of AWS S3's SDK and
improve usability.

Environment:

  • MinIO .NET SDK version: 6.0.3.0
  • .NET version: 8.0
  • Operating system: Windows
@minhaz109074 minhaz109074 changed the title Status code in PutObjectResponse is internal, unlike AWS S3's public implementation Status code in PutObjectResponse is internal, unlike AWS S3's implementation Sep 11, 2024
@harshavardhana harshavardhana transferred this issue from minio/minio Sep 11, 2024
@harshavardhana
Copy link
Member

Open SDK issues on relevant repos.

@n-goncalves
Copy link

Would be really nice if #1195 would be merged and released soon given how small of a change it is and how much of an inconvenience it can be (#1176).
In our own case, we ended up losing some files sent to a S3 compatible storage due to assuming that if no exception was thrown the upload must have been successful.

It is currently, to my knowledge impossible to detect those kind of issues if you don't access the internal values using Reflection.

Here's how you can do it for the time being:

...
var putObjectResponse = await client.PutObjectAsync(args);
var putObjectResponseType = putObjectResponse.GetType();
var httpStatusCode = (System.Net.HttpStatusCode) putObjectResponseType.GetProperty(
        "ResponseStatusCode", 
        System.Reflection.BindingFlags.NonPublic | 
        System.Reflection.BindingFlags.Instance
    )
 .GetValue(putObjectResponse);
var responseContent = (string) putObjectResponseType.GetProperty(
     "ResponseContent", 
    Reflection.BindingFlags.NonPublic | 
    Reflection.BindingFlags.Instance
)
.GetValue(putObjectResponse);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants