kreta/KretaWeb/Controllers/CacheController.cs
2024-03-13 00:33:46 +01:00

26 lines
870 B
C#

using System;
using System.IO;
using System.Web.Mvc;
using Kreta.Core;
namespace Kreta.Web.Controllers
{
[AllowAnonymous]
public class CacheController : Controller
{
/// <summary>
/// Wraps the stored MemoryStream into an Excel file.
/// </summary>
/// <param name="guid">Unique identifier of the file.</param>
/// <param name="fileName">File download name.</param>
/// <param name="contentType">Content type of the returned FileStream.</param>
/// <returns>The requested file as a FileStreamResult.</returns>
[HttpGet]
public ActionResult DownloadFile(Guid guid, string fileName, string contentType)
{
var stream = Cache.Get(guid) as MemoryStream;
return new FileStreamResult(stream, contentType) { FileDownloadName = fileName };
}
}
}