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

Issue with File Not Being Released After PutObjectAsync Upload #868

Open
sunny1028 opened this issue Sep 27, 2023 · 3 comments
Open

Issue with File Not Being Released After PutObjectAsync Upload #868

sunny1028 opened this issue Sep 27, 2023 · 3 comments

Comments

@sunny1028
Copy link

I apologize for my poor English!

PutObjectAsync can upload files successfully without any errors, and the uploaded file can be seen in the web management page. However, after using PutObjectAsync to upload a file, this local file remains locked by Minio and cannot be deleted, even though the upload was successful a long time ago.

Below is the code I used for testing, and I can ensure that the endpoint, accessKey, secretKey are all correct, and the filePath file exists and is not being used by other programs.

` string filePath = $"files/1.tmp";

    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));

    //System.IO.IOException:because it is being used by another process.
    File.Delete(filePath);`

Oh! By the way, I'm using Minio version 5.0.0.

@Noulens
Copy link

Noulens commented May 23, 2024

I have that exact same issue, did you find a solution ?

@HZ-GeLiang
Copy link

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);
.....

@Noulens
Copy link

Noulens commented Aug 2, 2024

Yes thanks a lot, stream does it

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

3 participants