Issue with File Not Being Released After PutObjectAsync Upload
🐞 Issue: Local file remains locked after successful PutObjectAsync upload I'm using the MinIO .NET SDK to upload a file using PutObjectAsync. The upload completes successfully — I can see the file in the MinIO web console — but afterward, the local file stays locked and cannot be deleted.
Even after waiting for one minute, attempting to delete the file results in an IOException indicating that the file is being used by another process.
🔁 Reproducible Code
if (!File.Exists(filePath))
{
Console.WriteLine($"file does not exist! [{filePath}]");
return;
}
var client = new MinioClient()
.WithEndpoint(endpoint)
.WithTimeout((int)TimeSpan.FromSeconds(5).TotalMilliseconds)
.WithCredentials(accessKey, secretKey)
.Build();
await client.PutObjectAsync(new PutObjectArgs()
.WithBucket("xys-patent-file")
.WithObject($"temp/test/{Path.GetFileName(filePath)}")
.WithFileName(filePath));
Console.WriteLine("success!");
Thread.Sleep(TimeSpan.FromMinutes(1));
// This throws:
// System.IO.IOException: The process cannot access the file because it is being used by another process.
File.Delete(filePath);
✅ Environment MinIO .NET SDK version: (e.g., v5.0.0)
🧐 What I’ve verified The file exists and is not in use by any other process before upload.
The upload succeeds without any error.
The file remains locked after upload, even after a delay.
❓Question Is this a known issue in the SDK? Do I need to manually dispose something after using PutObjectAsync? How can I release the lock so I can safely delete the local file?
Any help would be appreciated!
I have that exact same issue, did you find a solution ?
I'm using Minio version 4.0.0. Use stream to solve the problem
var bytes = File.ReadAllBytes(path);
using var stream = new MemoryStream(bytes);
.....
Yes thanks a lot, stream does it