Download large files in ASP.NET
cvetomir-todorov opened this issue · 1 comments
cvetomir-todorov commented
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.
martijn00 commented
Isn't it an idea to implement https://github.com/microsoft/Microsoft.IO.RecyclableMemoryStream and instead of a callback return that?