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

Download large files in ASP.NET #973

Open
cvetomir-todorov opened this issue Jan 3, 2024 · 1 comment
Open

Download large files in ASP.NET #973

cvetomir-todorov opened this issue Jan 3, 2024 · 1 comment

Comments

@cvetomir-todorov
Copy link

cvetomir-todorov commented Jan 3, 2024

I am simply referencing the incorrectly closed issue #225 about the same problem which is especially valid in ASP.NET and, consequently, for a big part, if not majority, of .NET applications.

Giving access to the underlying Stream for the file object stored in MinIO only via a callback is not idiomatic .NET code. It is weird and unusable in the use case where an ASP.NET controller needs to return the large file via return File(stream, mimeType);

[HttpGet]
public async Task<IActionResult> DownloadFile(
    [FromQuery] string bucketName,
    [FromQuery] string objectName)
{
    GetObjectArgs getObjectArgs = new GetObjectArgs()
        .WithBucket(bucketName)
        .WithObject(objectName)
        .WithCallbackStream(async (stream, ct) =>
        {
            // copying the stream to Response.Body results into
            // the entire file being loaded in the memory of the server
        });
    ObjectStat objectStat = await minio.GetObjectAsync(getObjectArgs);
    
    return File(whatStream???, objectStat.ContentType);
}

What is needed here is the actual Stream instance, so that it can be passed to the File method.

@cvetomir-todorov cvetomir-todorov changed the title Download large files via ASP.NET Download large files in ASP.NET Jan 3, 2024
@martijn00
Copy link
Contributor

Isn't it an idea to implement https://github.com/microsoft/Microsoft.IO.RecyclableMemoryStream and instead of a callback return that?

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

2 participants