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

PutObjectAsync ResponseStatusCode always 0 #1204

Open
xXAvoraXx opened this issue Nov 4, 2024 · 0 comments
Open

PutObjectAsync ResponseStatusCode always 0 #1204

xXAvoraXx opened this issue Nov 4, 2024 · 0 comments

Comments

@xXAvoraXx
Copy link

xXAvoraXx commented Nov 4, 2024

I can't find out what I'm doing wrong because it doesn't throw any errors. I am trying to send the file from IFormFile to minio as below, but when I go into minio I see that the file is not loaded. Minio is installed with default settings as docker-compose with one empty bucket and access keys defined.

BucketExistsAsync returns 'true'. There is no problem with the api key.

Version: .NET 6.0
Minio SDK: 6.0.3

                using var fileStream = person.Avatar.OpenReadStream();

                try
                {
                    bool found = await _minioClient.BucketExistsAsync(new BucketExistsArgs().WithBucket("my-bucket"));

                    Aes aesEncryption = Aes.Create();
                    aesEncryption.KeySize = 256;
                    aesEncryption.GenerateKey();
                    var ssec = new SSEC(aesEncryption.Key);

                    var putObjectArgs = new PutObjectArgs()
                        .WithBucket("my-bucket")
                        .WithObject("/businesses/" + businessId + "/people/" + person.Avatar.FileName)
                        .WithStreamData(fileStream)
                        .WithObjectSize(person.Avatar.Length)
                        .WithContentType("application/octet-stream");

                    var response = await _minioClient.PutObjectAsync(putObjectArgs);
                    Console.WriteLine("uploaded successfully");

                    StatObjectArgs statObjectArgs = new StatObjectArgs()
                        .WithBucket("my-bucket")
                        .WithObject("/businesses/" + businessId + "/people/" + person.Avatar.FileName);

                    ObjectStat objectStat = await _minioClient.StatObjectAsync(statObjectArgs);
                    Console.WriteLine(objectStat);
                }
                catch (MinioException e)
                {
                    Console.WriteLine("Error occurred: " + e);
                }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant