public async Task <HttpResponseMessage> Get(Guid fileId, [FromServices] GetFileHandler fh) { HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); var(stream, file) = await fh.Get(fileId); result.Content = new StreamContent(stream); result.Content.Headers.ContentType = new MediaTypeHeaderValue(file.ContentType); result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = file.FileName }; return(result); }
public async Task <IActionResult> Get(Guid fileId, [FromServices] GetFileHandler fh) { var(stream, file) = await fh.Get(fileId); return(File(stream, file.ContentType, file.FileName)); }