-
Notifications
You must be signed in to change notification settings - Fork 257
Closed
Description
Edited
After downgrading to version 6.0.0, the issue was resolved — the system correctly throws a "connection refused" exception when the MinIO service is not running.
Is this a bug, or am I using it incorrectly?(; ̄Д ̄)
Original
When the MinIO service is down, the SDK method PutObjectAsync does not throw an exception as expected. Instead, it returns a PutObjectResponse object where the ResponseStatusCode is 0, and no errors are exposed to the user. This leads to false assumptions that the upload was successful.
public async Task<System.Net.HttpStatusCode> UploadFileAsync(
string bucketName,
string objectKey,
IFormFile file,
string contentType = "application/octet-stream")
{
try
{
using var stream = file.OpenReadStream();
await _createBucketAsync(bucketName);
var args = new PutObjectArgs()
.WithBucket(bucketName)
.WithObject(objectKey)
.WithStreamData(stream)
.WithObjectSize(stream.Length)
.WithContentType(contentType);
var result = await _minioClient.PutObjectAsync(args);
return result.ResponseStatusCode;
}
catch(Exception ex)
{
Console.Error.WriteLine($"upload failed: {ex.Message}");
throw;
}
}Somewthere:
var status = await _minIOService.UploadFileAsync(_minioConfig.NodePublicReadBucket, objectKey, file, mimeType);
Console.WriteLine($"----- status code: {status} --------");
// other logic, store info into databaseOutput:
----- status code: 0 --------
lchforcom and GiannisKout
Metadata
Metadata
Assignees
Labels
No labels